function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
lnryanlnryan 

Visualforce to PDF

We have a sandbox that's been updated to the Summer '08 pre-release.
 
I created a very basic Visualforce to show my colleague the up-coming PDF functionality I saw demo-ed at Dreamforce, but couldn't figure out how to get the convert to PDF button to display. help?
 
[Update] __________
 
so, i found it in the component reference information for apex:page, but now when i try to test it out, I get an internal server error. Here's my code:
 
Code:
<apex:page standardController="Account" renderAs="pdf">
   <apex:detail subject="{!Account.id}"/>
</apex:page>

 
 
 


Message Edited by lnryan on 05-22-2008 02:08 PM
dchasmandchasman
I was able to create a page using the exact markup you provided in one of my sandbox orgs and the PDF rendered perfectly with and without a valid id=someAccountObjectId query parameter.

Do you have an error id from the page you can post here to allow us to find the underlying error report?


Message Edited by dchasman on 05-22-2008 06:18 PM
lnryanlnryan

all i got was teh slate grey error page with the following text

Visualforce Error


An internal server error has occurred
When I cut and pasted it I got a hidden field with a value "j_id0:j_id2"...not sure if it's relevant


Message Edited by lnryan on 05-22-2008 04:09 PM
jwetzlerjwetzler
Can you take yourself out of development mode and try again?  See if you get an error id that way.
lnryanlnryan

Now I get:

An internal server error has occurred
An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact support@salesforce.com. Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information. We apologize for the inconvenience.

Thank you again for your patience and assistance. And thanks for using Salesforce!

Error ID: 23645304-4

...at least it has an Error ID...
lnryanlnryan

oh...here's the page URL if it affects anything

Code:
https://tapp0.salesforce.com/apex/xRDaccount?id=001T000000959n4


 



Message Edited by lnryan on 05-22-2008 04:53 PM

Message Edited by lnryan on 05-22-2008 04:53 PM
dchasmandchasman
It is starting to look like something that is specific to the contents of your detail page - there is an underlying salesforce issue but we're unable to repro it. I'm going to send you a private message to request some more info to help us diagnose and fix this issue.


Message Edited by dchasman on 05-22-2008 08:48 PM
dchasmandchasman
The issue looks to be specific to one or more of the related lists being displayed (have not narrowed it further than that). <apex:detail relatedList="false"/> generates a pdf just fine.

In general the expected use for pdf generation is not to take a screen shot of online pages but is expected to be applied to pages that have been specifically designed to generate things like invoices, contact lists, etc in PDF form.
marie.tournemarie.tourne
It works great + it is necessary to add content type information :
 
Code:
<apex:page standardController="Account" renderAs="pdf" contenttype="application/pdf">
   <apex:detail relatedList="false"/>
   <apex:detail subject="{!Account.id}"/>
</apex:page>

 
Regards
dchasmandchasman
You should not need to add the contentType attribute - what change in behavior are you seeing when you added this?
lnryanlnryan
Is there any way besides adding and removing the lists for me to isolate the specific issues...we're hoping to use this functionality to generate contract documents that would involve a number of related lists as well as queried record set lists, so it's fairly significant for us.
mtbclimbermtbclimber
Any component that generates form elements - inputs, buttons, etc are going to be problematic in the conversion process. You should avoid using detail and relatedList in the page which is converted to PDF.

It is possible to iterate over related records without writing a query for use in PDF generation as demonstrated in this example:

http://wiki.apexdevnet.com/index.php/Visualforce_Quote2PDF

There are also some advanced formatting techniques for PDF included in this example:

http://wiki.apexdevnet.com/index.php/Visualforce_CaseHistoryTimeline

Share and enjoy!