Hello together,
I want print Project Invoices as PDF for sending them via email to customers.
The problem is, in some rare the generated PDF-File is corrupt. I am using the following code:
if(projInvoiceJour.RecId && mailAddressCustomer.RecId)
{
common.clear();
common = projInvoiceJour.data();
journalList = new RecordSortedList(common.tableId);
journalList.ins(common);
filePathWithoutExt = MYP_CustParameters::find().MYPAEC_PDFPathForInvoice;
if (!WINAPI::folderExists(filePathWithoutExt))
filePathWithoutExt = xInfo::directory(DirectoryType::Temp);
filename = strfmt("%1", mailInvoiceJournalLine.CustId + ‘-’ + projInvoiceJour.projInvoiceId + ‘-’ + time2str(timenow(),2,1)) + #FileExt;
filePath = filePathWithoutExt + “\” + filename;
//fill temporary container
tmp += [filePath];
printJobSettings = new PrintJobSettings();
printJobSettings.setTarget(PrintMedium::File);
printJobSettings.format(PrintFormat::PDF);
printJobSettings.fileName(filePath);
printJobSettings.preferredFileFormat(PrintFormat::PDF);
this.updatePrinterSettingsFormLetter(printJobSettings.packPrintJobSettings());
projFormLetter.updatePrinterSettingsFormLetter(printJobSettings.packPrintJobSettings());
args.name(reportStr(ProjInvoice));
args.object(journalList);
args.caller(projFormLetter);
new MenuFunction(menuitemoutputstr(ProjInvoiceCopy), MenuItemType::Output).run(args);
}
In the following samples you can see two printouts which are generated with exactly the same programm above.
The lines of the invoices are equals, only the customer is different.
-
Printout (Expected result)
-
Printout (Damaged printout)
If I primt the damaged PDF over the strandard PrintForm everything is fine.
Is there a problem in my code or is there another mistake.
Best regards