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
RRC007RRC007 

Printing multiple VF pages using one custom button??

is it possible to print two VF pages using one custom button? I have 2 pages that need to be maintained separately but wouldl ike my users to be able to print using only one button. Thoughts?
prageethprageeth

Hi;

What do you mean by the word "Print". Sending to a printer machine for a print-out?

RRC007RRC007
Yes. To clarify...I render the pages as PDFs but would like to only use one button to create as one PDF doc that i can then send them to the printer
prageethprageeth

Hello RRC

I am not still clear about your problem. However if you want to generate a pdf using two VF pages you have two options.

I assume that the names of your pdf pages are myPdfPage1 and myPdfPage2. 

 

1.Use following way if you want to get both pages in one pdf.  

 

myPdfPage1:(this is your first pdf page)

 

<apex:page renderAs="pdf">

<h1>This is page 1 </h1>

<div style="page-break-after:always;"/>

<apex:include pageName="myPdfPage2"/>

</apex:page>

 

 myPdfPage2:(this is your second pdf page)

<apex:page renderAs="pdf">

<h1>This is page 2 </h1>

</apex:page> 

 

On button click you have to call the myPdfPage1 page.

 

2.Use following way if you want to get both pages in two pdfs.

Here you need an intermediate page which is rendered as HTML. (I assume the name of it is myRequestPage) . On button click you need to call this page(Not a pdf page).

 

myRequestPage:

 

<apex:page>

<h1>Pdf generation Ok</h1>

<apex:iframe src="myPdfPage1"/>

<apex:iframe src="myPdfPage2"/>

</apex:page>  

 

 

 


 

 

 

 

 

 

 

 

 

 

 

RRC007RRC007

Prageeth,

Option one is what i was looking for. To throw another challenge into the equation, what if the object id for the second page comes from a custom object? i currently receive an error  that says 

 

Id value 001T000000EcNxH is not valid for the Account_Client_Plan__c standard controller

 

which is true. I need to pass the related ID value from a different controller. Is that possible?

Thanks,

RRC

prageethprageeth

Hello RRC;

In your case you have to do another little thing. I exactly can't say that how to do that in your case because I haven't seen your code. however I can show you a general example. 

 

Change your myPdfPage1 Page as below

 

<apex:page renderAs="pdf" standardController="Account" extensions="MyController">

<h1>This is page 1 </h1>

<div style="page-break-after:always;"/>

<apex:include pageName="myPdfPage2"/>

</apex:page>  

 

 Now in the controller you have to put the suitable id value for the second pdfPage as below.

 

public class MyController {

public MyController(ApexPages.StandardController controller){

Apexpages.currentpage().getparameters().put('id', 'xxxxxxxxx');//Id of Account_Client_Plan__c

}

} 

 

 I dont know whether you can understand what i am saying. If you can't understand this ill try to explain further.