Printing reports to PDF
Printing reports to PDF is extremely valuable for many companies. These documents can easily be saved and e-mailed for a variety of tasks like electronic invoicing. This recipe will show you how to develop this functionality.
Getting ready
PDFCreator must be installed on the system on which the code will be run. You can download it here:
http://sourceforge.net/projects/pdfcreator/
When installing, be sure not to install the ad-ware / spy-ware toolbar that comes with it. You may also want to turn-off the automatic updates for PDFCreator so that users do not end up on different versions of the software.
How to do it...
Create a new codeunit from Object Designer.
Add the following global variables:
Name
DataType
SubType
Length
PDFCreator
Automation
'PDFCreator'.clsPDFCreator
PDFCreatorError
Automation
'PDFCreator'.clsPDFCreatorError
PDFCreatorOption
Automation
'PDFCreator'.clsPDFCreatorOptions
DefaultPrinter
Text
100
Add a function named
SetupPDFCreator...