PDF Support

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Locked
User avatar
wakewatcher
Forum Members
Forum Members
Posts: 149
Joined: Fri Dec 28, 2007 12:33 am

PDF Support

Post by wakewatcher »

Is the forum search broke? I did a search for 'pdf' and turned up empty. I'm trying to figure out how to embed pdf content into a page. I can, of course, set an external link but then that flings me out of cmsms and off to parts unknown (dropbox in my case) where the pdf is stored. Is there a way to have a page display pdf content or if not is there a way for the link can bring the content into the page frame so as not to lose context of cmsms?


Just installed 1.11.4
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: PDF Support

Post by Dr.CSS »

The reading or showing of PDFs in a browser are browser dependent, none will just show the content of a PDF in a page on it's own, I use Foxit Reader and it will show them in the browser but never in the page, it would have to be copied into the page content...

Have you ever seen a web site that did what you ask..?
faglork

Re: PDF Support

Post by faglork »

wakewatcher wrote: Is there a way to have a page display pdf content or if not is there a way for the link can bring the content into the page frame so as not to lose context of cmsms?
You can use Google Docs to display the file - not just PDF, a whole bunch of formats! - in an IFRAME:
http://cms.faktori.de/gdocs.html

hth,
Alex
User avatar
wakewatcher
Forum Members
Forum Members
Posts: 149
Joined: Fri Dec 28, 2007 12:33 am

Re: PDF Support

Post by wakewatcher »

Excellent. I think this is the method I've seen used before (and it seems to work.) I made a page using:

Code: Select all

<__iframe src="http://docs.google.com/gview?url=http://example.com/mypdf.pdf&embedded=true" style="width:640px; height:624px;" frameborder="0"></__iframe>
and it did what I wanted. Thanks!

Now for a follow up question. This looks like a good opportunity for me to learn how to integrate something like this into a template so that my content providers don't have to insert this code fragment into the content section. Is there a smarty (or cmsms template creation) for dummies?
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: PDF Support

Post by Dr.CSS »

If you are going to have a lot of them like this you may want to use a module like Listit2...
User avatar
wakewatcher
Forum Members
Forum Members
Posts: 149
Joined: Fri Dec 28, 2007 12:33 am

Re: PDF Support

Post by wakewatcher »

So this approach works with Firefox and Chrome but IE pukes and tells the user "This content cannot be displayed in a frame" claiming the "publisher of this content does not allow it to be displayed in a frame." Any work around for this? (Other than the obvious "Don't use IE. :-) )
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: PDF Support

Post by calguy1000 »

Some simple googling helps.

I found this in just a few seconds.

http://stackoverflow.com/questions/1244 ... -vs-object

BTW. If your users are going to be embedding PDF's into pages
you could use a GCB to wrap the cruft. something like:

{global_content name='embed_pdf' file='path/to/file.pdf'}

and the GCB could read the params and output the appropriate <embed> or <object> or <__iframe> tags.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
User avatar
wakewatcher
Forum Members
Forum Members
Posts: 149
Joined: Fri Dec 28, 2007 12:33 am

Re: PDF Support

Post by wakewatcher »

That all supposes you know what to google for. I seem to be google search term impaired. But truth be told I did google and found the original solution on stackoverflow.

Thanks for the tip on Global Content Blocks. I'll dig into those next.

This is like taking a drink with a fire hose. Thanks for your patience.
User avatar
rotezecke
Power Poster
Power Poster
Posts: 411
Joined: Fri Apr 18, 2008 9:34 pm

Re: PDF Support

Post by rotezecke »

params for GCB?
User avatar
wakewatcher
Forum Members
Forum Members
Posts: 149
Joined: Fri Dec 28, 2007 12:33 am

Re: PDF Support

Post by wakewatcher »

@calguy
Thanks for the tip. It turns out that I think the problem isn't object or embed related but IE doesn't want to put something it believes to be someone's elses content in an iframe. I got the object stuff to work with FF and Chrome but like the way the google viewer displayed better. But I took to the opportunity to learn a bit more about UDTs and got half way there. So thanks for that. I made a UDT called embed_pdf as:

Code: Select all

if(!preg_match("/MSIE|iPad/", $_SERVER["HTTP_USER_AGENT"]))
 echo "<__iframe style='width: 640px; height: 624px;' src='http://docs.google.com/gview?url=" . $params['file'] . "&embedded=true' frameborder='0'></__iframe>";

else

  Echo "Window's IE will not display pdf content on this page nicely. <a href=" . $params['file'] . ">Click to display content in new page</a><br /><br />(Doesn't work on iPad yet either.)</object></p> <p><strong><object>This works as advertised with Firefox or Chrome.</strong></object> ";
(It doesn't display well on the iPad either so this is the stop gap for now.) In the pdf page I invoked the udt as: {emb_pdf file='path.pdf'}

So as mentioned this is the half step as it seems pretty silly to parse the user agent string on every page request that has a pdf in it. So the next thing I need to run into is how, for instance, on loading the 'home' page I can parse the user agent once then read it when I need it. I tried making an udt as:

Code: Select all

$agent = ($_SERVER["HTTP_USER_AGENT"]);
if (preg_match("/MSIE|iPad/", $agent)) 
{
    $result = "true";
} else {
    $result = "false";
}
$is_ie=$result;
$smarty->assign('is_ie',$is_ie);
and put it in my home page. Then in my other pdf pages tried putting in {$is_ie} to see if it had access to the smarty assignment from the earlier home page visit. It didn't seem to. If it did (or when I figure out how to access it I will use it as a parameter for the embed_pdf UDT. (Or I guess I could really kludge it and use session variables. Probably not a good idea.)
Locked

Return to “CMSMS Core”