Report output as pdf file.

Hi Guys,

I have a requirement to save the output of a report in a .pdf file i have find so many things but did not get any proper code to do the same.

I have written the following job to do the same but when i run the job it is not saving the file as pdf it is displaying the result on the screen.

Please help me fixing this issue.

static void Jobrep4(Args _args)
{
SalesTable SalesTable;
PrintJobSettings printJobSettings = new PrintJobSettings();
Args args = new Args();
;

printJobSettings.setTarget(PrintMedium::File);
printJobSettings.format(PrintFormat::PDF);
printJobSettings.fileName(‘d:\myfile2.pdf’);

select firstOnly SalesTable where SalesTable.salesid == ‘SO-100007’;
args.record(SalesTable);
args.caller(null);

new MenuFunction(menuitemoutputstr(POSInvoiceReport), MenuItemType::Output).run(args);
}

Hi Kami,

1.Comment the following codes in Init() method in POSInvoiceReport.

if (salesFormLetter)

{

salesFormLetterReport.parmDefaultCopyPrintJobSettings(new PrintJobSettings(salesFormLetter.printerSettingsFormletter(PrintSetupOriginalCopy::Copy)));

salesFormLetterReport.parmDefaultOriginalPrintJobSettings(new PrintJobSettings(salesFormLetter.printerSettingsFormletter(PrintSetupOriginalCopy::Original)));

salesFormLetterReport.parmUsePrintMgmtDestinations(salesFormLetter.usePrintManagement());

}

else if (printCopyOriginal == PrintCopyOriginal::OriginalPrint)

{

// Always use the print mgmt destinations when reprinting for the OriginalPrint case.

salesFormLetterReport.parmUsePrintMgmtDestinations(true);

}

2.Comment the following codes in Fetch() method in POSInvoiceReport.

element.unpackPrintJobSettings(salesFormLetterReport.getCurrentPrintSetting().parmPrintJobSettings().packPrintJobSettings());

element.printJobSettings().copies(salesFormLetterReport.getCurrentPrintSetting().parmNumberOfCopies());

3.Now your report will be saved as pdf file.