Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
QlikWorld 2020: Join us May 11 - 14, 2020 in Phoenix, AZ. Register early and save $400. Learn More
Highlighted
Not applicable

How to print individual sheets to separate PDFs with a script?

I've been working with script, for the first time, trying to print 20 separate sheets as PDFs in an automated way (or maybe to write one large PDF).  I have not (as yet) defined reports for these sheets.  At this time I just want to print them as sheets.

1. What is the script equivilent to menu: File, Print Sheet? (its not Print Report, PrintDocReport or PrintReportEx)

2. If I decided to use doc1.PrintAllSheets, how can I pass in the name of the PDF printer and the PDF file name I wish to write to?

Thx,

Brooks


Tags (4)
15 Replies
Not applicable

Re: How to print individual sheets to separate PDFs with a script?

I use a macro and the follwing script works for me.

Sub printRP

ActiveDocument.GetApplication.WaitForIdle(1000)

  ActiveDocument.PrintReport "RP01", "PDF-XChange 3.0", false

  ActiveDocument.GetApplication.Sleep 10000

  ActiveDocument.PrintReport "RP02", "PDF-XChange 3.0", false

  ActiveDocument.GetApplication.Sleep 10000

   ActiveDocument.PrintReport "RP03", "PDF-XChange 3.0", false

  ActiveDocument.GetApplication.Sleep 10000

  

   ActiveDocument.PrintReport "RP04", "PDF-XChange 3.0", false

  ActiveDocument.GetApplication.Sleep 10000

End Sub

Regards,

Gerrit

Not applicable

Re: How to print individual sheets to separate PDFs with a script?

Thanks for the post.

How do you specify the PDF file?

I don't see PDF-XChange 3.0 in my printer list in QV ...


Not applicable

Re: How to print individual sheets to separate PDFs with a script?

You have to Install PDF printer, There are many PDF printers

CutePDF

Bullzipp

PDFCreator

PDF-XChange 3.0

Not applicable

Re: How to print individual sheets to separate PDFs with a script?

As far as I know PDF-XChange 3.0 is installed out of the box together with QV.

However I am not the technical one here, and did not install QV.

Probably others may know where XChange 3.0 can be obtained.

Regards,

Gerrit

Not applicable

Re: How to print individual sheets to separate PDFs with a script?

Ok, I have CutePDF.

What is the code in the script to specify the PDF file name?

Not applicable

Re: How to print individual sheets to separate PDFs with a script?

You need to create a macro.

In the following lines i Have 4 reports RP01, RP02, RP03 and RP04.

These are my report names.

Sub printRP

ActiveDocument.GetApplication.WaitForIdle(1000)

  ActiveDocument.PrintReport "RP01", "PDF-XChange 3.0", false

  ActiveDocument.GetApplication.Sleep 10000

  ActiveDocument.PrintReport "RP02", "PDF-XChange 3.0", false

  ActiveDocument.GetApplication.Sleep 10000

   ActiveDocument.PrintReport "RP03", "PDF-XChange 3.0", false

  ActiveDocument.GetApplication.Sleep 10000

 

   ActiveDocument.PrintReport "RP04", "PDF-XChange 3.0", false

  ActiveDocument.GetApplication.Sleep 10000

End Sub

Regards,

Gerrit

Not applicable

Re: How to print individual sheets to separate PDFs with a script?

I understand that.  But where is it specified what folder to write to and what PDF file name to use?

Not applicable

Re: Re: How to print individual sheets to separate PDFs with a script?

Here is the Code

sub PrintReportPDFCreatorone

tempFolder = "C:\temp"

reportID = "RP01"

reportName = reportID    'Create the file name with path

reportFile = tempFolder & "\" & reportID & "_" & reportName & ".pdf" 'print the report

printReportPDF reportID, tempFolder 'Call the function 'Rename the report

end sub

Sub printReportPDF (oReport, pdfLocation)

Set WSHShell = CreateObject("WScript.Shell")

  WSHShell.RegWrite "HKEY_CURRENT_USER\Software\PDFCreator\OutputFile", pdfLocation

  WSHShell.RegWrite "HKEY_CURRENT_USER\Software\PDFCreator\BypassSaveAs", "1", "REG_SZ"

  msgbox("Before Print")

  ActiveDocument.PrintReport oReport, "CutePDF",false

  set WSHShell = nothing

end sub

Not applicable

Re: Re: How to print individual sheets to separate PDFs with a script?

Thanks for the code, making progress.  Still a bit to go ...

I changed to:

PrintReportPDF reportID, reportFile

Also on my system the printer is named: "CutePDF Writer"

The problem is that bypassing the Save As is not working.  A Save As dialog window is appearing.

Maybe "1" should be something else?