|

Print Sales Invoice Report in PDF / HTML / RTF / ASCII etc., format through code

I have observed that lot of developers face difficulty in printing the Sales Invoice report into file system through code. Here is the code snippet for it.
SalesFormLetter salesFormLetter;
PrintJobSettings printJobSettings;
CustInvoiceJour custInvoiceJour;
SalesId salesId;
#File
salesid = “SO-100010”;
salesFormLetter = SalesFormLetter::construct(DocumentStatus::Invoice,false);
printJobSettings = new PrintJobSettings();
printJobSettings.setTarget(PrintMedium::File);
printJobSettings.format(PrintFormat);
printJobSettings.fileName( ‘//10.0.57.22/AOSPrintShare//’ + salesId+#pdf );
printJobSettings.warnIfFileExists(false); SalesFormLetter.updatePrinterSettingsFormLetter(printJobSettings.packPrintJobSettings());
select custInvoiceJour where custInvoiceJour.SalesId == salesId;
custInvoiceJour.printJournal(salesFormLetter);
In the above Code, I have tried to print a Sales Invoice Report in pdf format. In the same way by changing the extension you can print the same report in all valid formats like html, rtf, ascii etc.,

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

0 Comments

  1. Hello Mr. Giridhar Raj, I'd like to print sales invoice from code too. But i have little problem with look of the invoice in PDF format. Problem is that pdf invoce has approximaty 5mm border compare to the printed look of the same sales invoice report. Same problem i have with print to PDF from AX form.
    So, is it possible to change setting of PDF converter in AX?

  2. Hi, Im using above code to save our payslip as PDF, and it is working like a charm. But for security reason I would like to password protect the PDF files, how is this possible ?