39

I have an embed tag like this:

<embed src="../../Content/PDF/StockReport.pdf#zoom=50" width="100%" height="100%">

the #zoom=50 is a parameter that tells the pdf reader to zoom to 50%. This works in all browsers but google chrome because chrome has a built in pdf viewer.

How can I pass this same parameter to google chrome's pdf viewer ?

BentOnCoding
  • 27,307
  • 14
  • 64
  • 92
  • chrome doesn't use adobe's code at all for pdf viewing, so there may not be any equivalent, you could try css styling the embed somehow. – Spudd86 Aug 19 '11 at 19:26

4 Answers4

42

After checking various chrome bug reports, I can confirm that Google Chrome ignores the default functionality of Adobe PDF viewer. At the time of this answer there is no way to pass parameters (like zoom) to the Chrome PDF viewer.

EDIT

Progress has been made on this by the Chromium team. The work was being done with reference to both the Acrobat SDK and RFC 3778. As of Dec 2017 Chromium added support for view, zoom, page, toolbar and nameddest and later made it into Chrome.

Community
  • 1
  • 1
BentOnCoding
  • 27,307
  • 14
  • 64
  • 92
  • 8
    It does understand the `page` parameter. Any others? – adavid Feb 04 '13 at 14:40
  • It also ignores `view`. I can confirm that years after this question, it still ignores `zoom`, but recognizes `page`. – Smig Mar 21 '14 at 19:06
  • 5
    Here is the Chromium Bug Report regarding PDF Open Parameters support: https://code.google.com/p/chromium/issues/detail?id=64309 – sompylasar Apr 16 '14 at 10:33
  • 2
    It supports a limited set. Namely `page=x` `scale=x`, and `toolbar=1|0` – samnau Mar 29 '17 at 17:45
  • By any chance can we rotate PDF using any parameter in chrome ? I mean by default I want to render PDF left rotated. – SaiSurya Mar 05 '21 at 12:59
20

Use iframe:

  1. It works in Mozilla
  2. It works in Chrome
  3. No Javascript needed

Example:

<div id="mypdf">
<iframe src="/cennik.pdf#zoom=65" style="width: 100%; height: 800px;" frameborder="0" scrolling="no">
        <p>Your web browser doesn't support iframes.</p>
   </iframe>
</div>
damian1baran
  • 1,307
  • 1
  • 14
  • 13
14

Chrome 86 (2020) status of parameters - From the chromium issue (and my notes)

  • view: implemented (accepts Fit, FitH, FitV - for vertical resp horizontal fit)
  • toolbar: implemented (hides top-bar, but not zoom-buttons bottom right)
  • zoom: implemented
  • scrollbar: not implemented
  • page: implemented
  • nameddest: implemented
  • search: filed bug 792647 to track separately
  • navpanes: does not apply
  • statusbar: does not apply

If you want the search functionality to be implemented go to this issue, login, and click the star (top left) to vote on it

BobbyTables
  • 4,481
  • 1
  • 31
  • 39
  • 1
    Thanks for posting this. `viewrect` also seems not to be implemented. It may be useful to collect a similar list for Firefox maybe: they seem to have implemented `zoom` but have the coordinates inverted (a bug). – ShreevatsaR Dec 30 '20 at 00:05
  • The Firefox bug about the y coordinate being upside-down is https://github.com/mozilla/pdf.js/issues/2843 – ShreevatsaR Dec 31 '20 at 06:19
5

It appears that a later release of Chrome may now be the answer. I had success passing zoom and page parameters through an object tag.

Case:

  • Set zoom to 200%
  • Set page to 2

Example:

<object data="https://your.url/docs/123.pdf#zoom=200&page=2" 
        type="application/pdf" 
        width="100%" 
        height="100%"> 
</object>
Matt Plank
  • 333
  • 6
  • 12
  • `#view=fit` works now. I didn't find documentation but there is an [issue](https://bugs.chromium.org/p/chromium/issues/detail?id=64309) on chromium which covered it and the rest of the parameters. – buckaroo1177125 Apr 24 '19 at 17:36