Skip to main content Skip to footer

How to merge multiple VSReports in a single PDF

Integrating multiple reports in a single PDF file is helpful in many ways. It allows customers/clients to have a better view of the company reports and analyze them. There is no direct solution available to generate such reports. However we can achieve this by appending multiple reports to VSPrinter and then use VSPDF object to convert the VSPrinter document to a single PDF file. Following code blocks show the required implementation.

'Loading multiple reports and rendering them as VSPrint files .vp  

Private Sub cmdMerge_Click()  
  vsr.Load App.Path & "\\Tricky.xml", "Employees" 'vsr= VSReports  
  vsr.RenderToFile App.Path & "\\vsprint1.vp", vsrVSPrinter  
  vsr.Load App.Path & "\\Tricky.xml", "Products"  
  vsr.RenderToFile App.Path & "\\vsprint2.vp", vsrVSPrinter  
  vsr.Load App.Path & "\\Tricky.xml", "Order Report No Params"  
  vsr.RenderToFile App.Path & "\\vsprint3.vp", vsrVSPrinter  
End Sub 

Now after rendering multiple .vp files we need to merge them into a single VSPrint document


'Appending multiple .vp files to VSPrint document  

Private Sub cmdGen_Click()  
  vp.LoadDoc "vsprint1.vp", 1  
  vp.LoadDoc "vsprint2.vp", 1  
  vp.LoadDoc "vsprint3.vp", 1  
End Sub  

Rendering VSPrint doc to PDF using VSPdf

'Rendering VSPrint Doc into PDF  

Private Sub cmdGen\_PDF\_Click()  
  vsp.ConvertDocument vp, App.Path & "\\new.pdf"  ' COnverting VSPrint into VSPdf  
End Sub