How to set height on PDF file when linked to from HTML?

大憨熊 提交于 2019-12-24 07:27:09

问题


I've just created a link which when clicked will take the user to a PDF file.

However when I open the PDF document on the mobile it shows only 3/4 of the page. The rest on the page is just black.

Is there a way in the CSS I can set a default zoom on the PDF?

HTML code:

<a href="privacyStatement.pdf" class="item icon icon-accessory item-icon-right">
  Privacy Statement
  <i class="icon ion-chevron-right icon-accessory"></i>
</a>

回答1:


Have a look at this Adobe document:

  • Parameters for Opening PDF Files (http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_open_parameters.pdf#G4.1500435)

It describes different ways to set URL modifiers in a HTTP request. But only Adobe PDF viewers will honor most of them. Some may only work if the requested PDF is 'web optimized' (a.k.a. as 'linearized'). Some viewers made by other vendors may support some of these only.

You may be able to link to a specific page within a PDF hosted on the web. So it could open on this page instead of the title page. The page=<pagenum> parameter is meant for that.

For example, try if your viewer jumps from the following link to Page 3 of above PDF Opening Parameter reference. (The previous link requests the viewer to open the destination PDF directly at page 3).

Other parameters are useful too:

  • #search=<wordList>.
    Example: http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_open_parameters.pdf#search="commentID"

  • #nameddest=<destination>
    The PDF of course must contain such a named destination. Otherwise it will not work. You can create named destinations within a PDF with Acrobat (not with Adobe Reader, though!): 1. Go to the desired location in the PDF. 1. Click 'View > Navigation Tabs > Destinations'. 1. Go to 'Options', choose 'Scan Document' 1. Once scan is completed, select 'New Destination' from the 'Options' menu; then enter the name you want.

    Important note: Named destinations are not the same as bookmarks. There is no documented URL parameter which would link to a bookmark.

  • #comment=<commentID>
    Specifies a comment on a given page in the PDF document. Use the #page=.... command before this on. For example: #page=1&comment=fd22-457c-84aa-2cf5bed5-452fde0e.

Zoom

Yes, you can also request a zoom level on a specific page:

  • #page=3&zoom=100
    This would request a 100% zoom level for page 3.

  • #page=3&view=Fit
    This is probably what you want! It asks to display page 3, with its contents magnified just enough to fit the entire page within the window both horizontally and vertically. If the required horizontal and vertical magnification factors are different, it uses the smaller of the two, centering the page within the window in the other dimension.

However, if it works is fully dependent on the viewer software, there is no guarantee for it to work. Good luck with that!

More details in the initially linked Adobe PDF file....



来源:https://stackoverflow.com/questions/29749780/how-to-set-height-on-pdf-file-when-linked-to-from-html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!