You need to sign in to do that
Don't have an account?
Chie Men
How to open generated PDF file to a browser instead of making it as an attachment?
Hi,
I have a "Generate PDF" button in my Asset detail page. I was able to generate a PDF file but instead of making it as an attachment to the Asset detail page. Here is the code I get online to generate a PDF file:
Blob pageData; //variable to hold binary PDF data.
if(!Test.isRunningTest()){ // for code coverage
pageData = thePage.getContentAsPDF();
} else {
pageData = Blob.valueOf('This is a test.');
}
//create attachment
Attachment att = new Attachment(
ParentId=recordId,
Body=pageData,
Name= lname + 'Asset_' + DateTime.now().formatLong() + '.pdf'
);
insert att;
Instead of attaching the pdf file, I want it to open in a new browser tab.
Thank you.
I have a "Generate PDF" button in my Asset detail page. I was able to generate a PDF file but instead of making it as an attachment to the Asset detail page. Here is the code I get online to generate a PDF file:
Blob pageData; //variable to hold binary PDF data.
if(!Test.isRunningTest()){ // for code coverage
pageData = thePage.getContentAsPDF();
} else {
pageData = Blob.valueOf('This is a test.');
}
//create attachment
Attachment att = new Attachment(
ParentId=recordId,
Body=pageData,
Name= lname + 'Asset_' + DateTime.now().formatLong() + '.pdf'
);
insert att;
Instead of attaching the pdf file, I want it to open in a new browser tab.
Thank you.