Problem with PDF Printing - Project invoice

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.

  1. Printout (Expected result)

  2. 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

Hello together,

I have found out that the generated PDF is absolutely correct. But the attachment in the mail is damaged.

I have done a hex diff. The only problem is that in one line a 2E is to much. When I remove the 2E in hex-editor the PDF works well.

Do someone know this behaviour? Has someone an explanation for this?

Best regards

Cetim

Hello together,

have solved the problem. I use sysmailer.quicksend() instead of sysMailer.SendMail()

Best regards

Cetom