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
sai ramsai ram 

how to display generated pdf in two columns

public with sharing class AccountPDFGenerator { public static final String FORM_HTML_START = '<HTML><BODY>'; public static final String FORM_HTML_END = '</BODY></HTML>'; public static void generateAccountPDF(Account account) { String pdfContent = '' + FORM_HTML_START; try { pdfContent = '' + FORM_HTML_START; pdfContent = pdfContent + '<H2>Account Information in PDF</H2>'; //Dynamically grab all the fields to store in the PDF Map<String, Schema.SObjectType> sobjectSchemaMap = Schema.getGlobalDescribe(); Schema.DescribeSObjectResult objDescribe = sobjectSchemaMap.get('Account').getDescribe(); Map<String, Schema.SObjectField> fieldMap = objDescribe.fields.getMap(); //Append each Field to the PDF for(Schema.SObjectField fieldDef : fieldMap.values()) { Schema.Describefieldresult fieldDescResult = fieldDef.getDescribe(); String name = fieldDescResult.getName(); pdfContent = pdfContent + '<P>' + name + ': ' + account.get(name) + '</P>'; } pdfContent = pdfContent + FORM_HTML_END; }catch(Exception e) { pdfContent = '' + FORM_HTML_START; pdfContent = pdfContent + '<P>THERE WAS AN ERROR GENERATING PDF: ' + e.getMessage() + '</P>'; pdfContent = pdfContent + FORM_HTML_END; } attachPDF(account,pdfContent); } public static void attachPDF(Account account, String pdfContent) { try { Attachment attachmentPDF = new Attachment(); attachmentPDF.parentId = account.Id; attachmentPDF.Name = account.Name + '.pdf'; attachmentPDF.body = Blob.toPDF(pdfContent); //This creates the PDF content insert attachmentPDF; }catch(Exception e) { account.addError(e.getMessage()); } } }

User-added image
ANUTEJANUTEJ (Salesforce Developers) 
Hi Sai Ram,

I think you can create a vf page with two columns to show the necessary data and then render it as pdf, let me know if this helps, additionally, I found an implementation that might help, below is the link to it:

>>https://trailblazers.salesforce.com/answers?id=9063A000000pns6

Regards,
Anutej