Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set fit width when embedding pdf in Chrome?

When I embed a pdf to view on Chrome/ Firefox , no matter I set width / set the parameter , it does not change the width of the pdf content, the only thing I can control is the pdf viewer size but not pdf page size, are there any way to control it? thanks

<object type="application/pdf" data="2010%20AHS%20XC%20Results.pdf" width="1500" height="1200"></object>

<object type="application/pdf" data="2010%20AHS%20XC%20Results.pdf#view=fit" width="1500" height="1200"></object>

   <object type="application/pdf" data="2010%20AHS%20XC%20Results.pdf" width="1500" height="1200">
    <parm name="view" value="fit/>
</object>

None of the above code work

like image 765
user782104 Avatar asked Aug 28 '13 01:08

user782104


1 Answers

I had the exact same problem and found after quite a lot of digging that the problem is with the Chrome pdf viewer. It does not accept url open parameters like adobe does, see https://code.google.com/p/chromium/issues/detail?id=64309.

In order to test this I typed in "about:plugins" in Chrome, disabled Chrome pdf viewer and enabled the adobe viewer. Once I did this the following code worked for me:

<object type="application/pdf" data="2010%20AHS%20XC%20Results.pdf" width="1500" height="1200">
<parm name="view" value="FitH" /></object>

I understand this is not a real fix as you can't control whether the visitors to your site have this plugin or not, but wanted to leave this answer here so that others who see this post know that the issue is with Chrome Pdf viewer not accepting URL open parameters as of 11/21/14 and so will not waste their time looking for issues in their code.

like image 64
Dave Avatar answered Oct 09 '22 11:10

Dave