Qlik Community

QlikView Documents

Documents for QlikView related information.

Print Report to PDF with open source PDFCreator

angemilk
Visitor

Print Report to PDF with open source PDFCreator

Sub Print

  PrintPDF("Your File Name","RP01")

End Sub

Function PrintPDF(NamePDF, qvObject)

  Dim vPath

  vPath= "C:\"

  Set PDFCreator = CreateObject("PDFCreator.clsPDFCreator")

  PDFCreator.cStart ("/NoProcessingAtStartup")

   

  PDFCreator.cOption("UseAutosave") = 1 ' Enable autosave

    PDFCreator.cOption("UseAutosaveDirectory") = 1 ' Use a specific save directory

  'Comment this line if you already set on PDFCreator a directory where you wont to save a PDFfile

  'PDFCreator.cOption("AutosaveDirectory") =vPath  ' Set autosave directory from variable  'ActiveDocument.getVariable("TempPath").GetContent.String ' Set autosave directory from set analisis variable

    PDFCreator.cOption("AutosaveFormat") = 0 '  0=PDF, 1=PNG, 2=JPG, 3=BMP, 4=PCX, 5=TIFF, 6=PS, 7= EPS, 8=ASCII

    PDFCreator.cOption("AutosaveFilename") = NamePDF ' & ".pdf"' set the filename, optionally you can get the Caption of the object and use it as Filename

    PDFCreator.cPrinterStop = False          'printer enabled

  ActiveDocument.PrintDocReport qvObject, "PDFCreator"    'print

  ActiveDocument.GetApplication.Sleep 5000    'stop my macro for 5 sec, its time is need to save a PDF

  PDFCreator.cClearCache()    'clear cache

  PDFCreator.cClose() 

end function

Labels (1)
Comments
bonkornwit
Contributor

Hey Angelina.

Could does this code still work?

When i tried it, it says "Cannot use parentheses when calling a Sub" on the PrintPDF("Your File Name","RP01") line,

Im using the latest PDF Creator, could this be the problem?

alexandre_ciott
New Contributor II

Hey Bon,

when you call a function, you can't use parentheses. The correct is PrintPDF "Your File Name", "RP01"

Alexandre

riccardozenere
Contributor III

Or you can add a "call" before PrintPDF

It would  be like this: call PrintPDF("Your File Name", "RP01")

jaceknoden
Contributor

Hello,

I got this error message:

"ActiveX component can not create object .: 'PDFCreator.clsPDFCreator'  "

on line 8:

Set PDFCreator = CreateObject("PDFCreator.clsPDFCreator")

Can you help me?

Regards

Jacek.

bonkornwit
Contributor

Hi Jacek.

i was having the same problem with PDFCreator too, I think the script works on earlier version of PDFCreator, 1.0 if not mistaken,

Re: Macro export Reports to multiple PDF

jaceknoden
Contributor

Hello bonkornwit

Thank you  for help. It's works.

Reagrds

Jacek.

Version history
Revision #:
1 of 1
Last update:
‎12-18-2014 03:35 PM
Updated by: