Issue with PDF Report

Shabna_NazarShabna_Nazar Member Posts: 10
Hi,
I'm having an issue with PDF report in navision.I have used the code below to print and save as PDF. When trying to print a particular Purchase Order, it is printing all the POs present in the system. Also I used the same code for Sales Order, for that it is always printing the 1st Sales Order only. Please help me in this issue.

OnOpenForm() trigger
IF ISCLEAR(PDFCreatorG) THEN
CREATE(PDFCreatorG);
IF ISCLEAR(PDFCreatorErrorG) THEN
CREATE(PDFCreatorErrorG);
ReportIDG := REPORT::Order;
IF ObjectG.GET(ObjectG.Type::Report,'',ReportIDG) THEN;
FileDirectoryG := 'C:\';
FileNameG := 'Purchase Order.pdf';
PDFCreatorErrorG := PDFCreatorG.cError;
IF PDFCreatorG.cStart('/NoProcessingAtStartup',TRUE) = FALSE THEN
ERROR('Status: Error: ' + PDFCreatorErrorG.Description);

OnPush() trigger
WindowG.OPEN('processing');
WindowisOpenG := TRUE;
IF FileNameG = '' THEN
ERROR('Please specify what the file should be saved as');
ObjectG.GET(ObjectG.Type::Report,'',ReportIDG);
PDFCreatorOptionG := PDFCreatorG.cOptions;
PDFCreatorOptionG.UseAutosave := 1;
PDFCreatorOptionG.UseAutosaveDirectory := 1;
PDFCreatorOptionG.AutosaveDirectory := FileDirectoryG;
PDFCreatorOptionG.AutosaveFormat := 0; //PDF file, you can also save in other formats
PDFCreatorOptionG.AutosaveFilename := FileNameG;
PDFCreatorG.cOptions := PDFCreatorOptionG;
PDFCreatorG.cClearCache();
DefaultPrinterG := PDFCreatorG.cDefaultPrinter;
PDFCreatorG.cDefaultPrinter := 'PDFCreator';
PDFCreatorG.cPrinterStop := FALSE;
REPORT.RUNMODAL(ReportIDG,FALSE,TRUE);

Comments

  • kinekine Member Posts: 12,562
    Of course, you do not pass the Record filtered for the document you want to print in your last command REPORT.RUNMODAL. You need to add one parameter there... ;-)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.