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
Meggan Landis 2Meggan Landis 2 

Using apex:detail in a visualforce page, can you replicate the layout?

Hi all,
I have a button that generates and attached (to notes and attachments) a pdf version of a custom object I have called PreAdmission. Generally, the process is working - it's taking all fields from this object, adding them to a pdf and attaching that pdf as I want it to, but the issue I have is that the formatting on the pdf is awful. All of the fields are jumbled together, and it's difficult to read because of the spacing. I need to include apex:detail so it includes all fields (there are a ton so I don't want to have to add them individually), but is there any way to replicate the existing page layout of the object. I basically want the pdf to look exactly as it would if I would use the 'Printable View' option. The code I have on the visualforce page I am using is below. Any help would be greatly appreciated. Thank you!



<apex:page standardController="Pre_Admission__c" renderAs="pdf"> <apex:detail subject="

{!Pre_Admission__c.Id}" relatedList="false" title="false"/>

</apex:page>
VinayVinay (Salesforce Developers) 
Hi Meggan,

Check below examples for custom Printable View using vf page.

https://techman97.wordpress.com/2013/07/22/visualforce-page-printable-view/
http://salesforcecodes.com/print-the-details-of-page-in-pdf-using-visualforce-page-in-salesforce/

Also check below Appexchange tool
https://appexchange.salesforce.com/listingDetail?listingId=a0N3A00000EFom3UAD

Please mark as Best Answer if above information was helpful.

Thanks,
Meggan Landis 2Meggan Landis 2
Thanks, but I don't think this really applies. I was trying to generate a pdf of my Salesforce record through VF so I could automatically generate and attach it. I think the link above just shows me how to add a print view button to a page.