3

I have a problem with rendering pdf documents using tag in VF page in mobile browsers.

Please, look, this is code of VF page:

<apex:page id="thePage" controller="myctrl"  action="{!doAction}" cache="false"> <object type="{!attach.ContentType}" data="servlet/servlet.FileDownload?file={!fileId}" id="c"> </object> </apex:page>

If i open this page in browsers in my PC - pdf is rendered successfully, but if i try to open this page in mobile broswers - i'm available to see only first page of pdf doc.

Did anybody solve this issue?

Thank you.

1

This will probably have something to do with your pdf reader on your mobile device.

As salesforce only renders the PDF out of HTML/CSS and then provides the user's browser a link to that PDF, which basically means that it is up to the browser to handle the pdf. Either download it, or open with something like Adobe Acrobat (I think chrome has native PDF reading support build in)

1

Two (mutually exclusive) options that might work:

  1. If you are not already doing so, I'd try keeping everything the same and setting the PageReference redirect attribute to true. If you are already doing that, or if doing so does not have the desired effect, then please consider option 2.

  2. Instead of using a VF page, just use the link to the PDF itself instead. So, in your controller, instead of returning a PageReference to a VF page, return one to the relative URL of the PDF file instead:

    servlet/servlet.FileDownload?file=fileId

0

My workaround:

Initially, I had a detail page button on the record that opened a link like below to the VF page that is to be rendered as pdf

Example /apex/VFPage?id=a2t5E000000IO7b&mode=pdf

THIS DID NOT WORK ON THE SF1 mobile app

SOLUTION:

Create an SF site and let the detail page button open the site instead of directly opening the VF page through /apex

EXAMPLE https://whatever-org.cs84.force.com/VFPage?id=a2t5E000000IO7b&mode=pdf**

New contributor
Lian Bond is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.