Sales Invoice Convert to PDF Using Posted Invoice Form

abhinavmehraabhinavmehra Member Posts: 34
Hi all...

I have created 1 Button in Posted Sales Invoice Form.

Like PDF

writen the code as



Setup.SetupPDFCreator('D:\Robo\','Test.pdf');
SalesInvHeader.RESET;
IF GET("No.") THEN BEGIN
MESSAGE('%1,%2',"No.");
REPORT.RUNMODAL(REPORT::"Vendor - List", FALSE,FALSE);
Setup.RUN;
SMTP.RUN;
END;

Setup is my Codeunit for PDF

Codes are

variables:

PDFCreator Automation 'PDFCreator'.clsPDFCreator
PDFCreatorErr Automation 'PDFCreator'.clsPDFCreatorError
PDFCreatorOptions Automation 'PDFCreator'.clsPDFCreatorOptions
DefaultPrinter Text 100
SalesInvHeader Record Sales Invoice Header

Documentation()

OnRun()
//SetupPDFCreator(ENVIRON('TEMP'), 'Test.pdf');
{SetupPDFCreator('D:\Robo\','Test.pdf');
SalesInvHeader.RESET;
IF SalesInvHeader.GET(SalesInvHeader."No.") THEN
REPORT.RUNMODAL(REPORT::"Vendor - List", FALSE,"No." );
//WaitUntilFileExists('D:\Robo\Test.pdf');
//IF WaitUntilFileExists(ENVIRON('Temp') + '\Test.pdf') THEN
//HYPERLINK(ENVIRON('Temp') + '\Test.pdf');
}
ClearPDFCreator;

SetupPDFCreator(FileDir : Text[1024];FileName : Text[1024])
IF ISCLEAR(PDFCreator) THEN
CREATE(PDFCreator, TRUE, TRUE);

IF ISCLEAR(PDFCreatorErr) THEN
CREATE(PDFCreatorErr, TRUE, TRUE);

PDFCreatorErr := PDFCreator.cError;

IF PDFCreator.cStart('/NoProcessingAtStartup', TRUE) = FALSE THEN
ERROR('Status: Error:' + PDFCreatorErr.Description);

PDFCreatorOptions := PDFCreator.cOptions;
PDFCreatorOptions.UseAutosave := 1;
PDFCreatorOptions.UseAutosaveDirectory := 1;
PDFCreatorOptions.AutosaveDirectory := FileDir;
PDFCreatorOptions.AutosaveFormat := 0;
PDFCreatorOptions.AutosaveFilename := FileName;
PDFCreator.cOptions := PDFCreatorOptions;
PDFCreator.cClearCache();
DefaultPrinter := PDFCreator.cDefaultPrinter;
PDFCreator.cDefaultPrinter := 'PDFCreator';
PDFCreator.cPrinterStop := FALSE;

WaitUntilFileExists(FileName : Text[1024])
i := 0;
maxi := 10;
WHILE (i < maxi) DO BEGIN
IF FILE.EXISTS(FileName) THEN BEGIN
i := maxi;
FileFound := TRUE;
END ELSE BEGIN
i += 1;
SLEEP(1000);
END;
END;
//EXIT(FileFound);

ClearPDFCreator()
PDFCreator.cDefaultPrinter := DefaultPrinter;
CLEAR(PDFCreatorErr);
CLEAR(PDFCreator);

SMTP is my SMTP Codeunit to ranfer thought the PDF to Mail


but the issue is it Create the all Invoices in 1 PDF...
I need only single invoice according to the Sales Invoice No.

Please help me to solve this.

Thanks in advance.....

Comments

Sign In or Register to comment.