Saving Sales Invoice report in PDF format

pushpraj1008
Member Posts: 33
Hi All,
I'm trying to calling Sales Invoice report (206) from another report, whose data item is "Sales Invoice Header'.
I want to print each sales invoice report individually into PDF Format( according to Sales Invoice Header - "No." wise), but when i call Sales Invoice, the system is getting hang for printing report.
1) When i give the filters on report (say Invoice No. :01000..010010), it is printing only first Invoice no. & getting hang.
2) If i club all the Invoice No. & print into one file, it is printing fine.
3) i didn't get why it is getting hang for printing each individual file into PDF format.
4) DifferentFile is the boolean which accepts whether Sales invoice file is printed separately for each invoice into PDF format.
Below is the code:
IF gBlnSaveToPDF THEN BEGIN
FinvoiceSetup.TESTFIELD(FinvoiceSetup."Finvoice Invoice App. File");
IF ISCLEAR(gPDFCreator) THEN
CREATE(gPDFCreator);
IF ISCLEAR(gPDFCreatorError) THEN
CREATE(gPDFCreatorError);
lIntReportID :=REPORT::"Sales - Invoice";
lTxtFileDirectory :=FinvoiceSetup."Finvoice Invoice App. File";
gPDFCreatorError := gPDFCreator.cError;
IF gPDFCreator.cStart('/NoProcessingAtStartup',TRUE) = FALSE THEN
ERROR('Status: Error: ' + gPDFCreatorError.Description);
gPDFCreatorOption := gPDFCreator.cOptions;
gPDFCreatorOption.UseAutosave := 1;
gPDFCreatorOption.UseAutosaveDirectory := 1;
gPDFCreatorOption.AutosaveDirectory := lTxtFileDirectory;
gPDFCreatorOption.AutosaveFormat := 0;
gPDFCreatorOption.AutosaveFilename := iTxtFileName;
gPDFCreator.cOptions := gPDFCreatorOption;
gPDFCreator.cClearCache();
gTxtDefaultPrinter := gPDFCreator.cDefaultPrinter;
gPDFCreator.cDefaultPrinter := 'PDFCreator';
gPDFCreator.cPrinterStop := FALSE;
IF NOT DifferentFile THEN BEGIN
lRecSalesInvHead.INIT;
lRecSalesInvHead.RESET;
lRecSalesInvHead.SETFILTER(lRecSalesInvHead."No.","Sales Invoice Header".GETFILTER("Sales Invoice Header"."No."));
IF lRecSalesInvHead.FINDFIRST THEN
REPORT.RUNMODAL(lIntReportID,FALSE,TRUE,lRecSalesInvHead);
END ELSE BEGIN
lRecSalesInvHead.INIT;
lRecSalesInvHead.RESET;
lRecSalesInvHead.SETRANGE(lRecSalesInvHead."No.","Sales Invoice Header"."No.");
IF lRecSalesInvHead.FINDFIRST THEN
REPORT.RUNMODAL(lIntReportID,FALSE,TRUE,lRecSalesInvHead);
END;
gPDFCreator.cDefaultPrinter :=gTxtDefaultPrinter;
END;
I'm trying to calling Sales Invoice report (206) from another report, whose data item is "Sales Invoice Header'.
I want to print each sales invoice report individually into PDF Format( according to Sales Invoice Header - "No." wise), but when i call Sales Invoice, the system is getting hang for printing report.
1) When i give the filters on report (say Invoice No. :01000..010010), it is printing only first Invoice no. & getting hang.
2) If i club all the Invoice No. & print into one file, it is printing fine.
3) i didn't get why it is getting hang for printing each individual file into PDF format.
4) DifferentFile is the boolean which accepts whether Sales invoice file is printed separately for each invoice into PDF format.
Below is the code:
IF gBlnSaveToPDF THEN BEGIN
FinvoiceSetup.TESTFIELD(FinvoiceSetup."Finvoice Invoice App. File");
IF ISCLEAR(gPDFCreator) THEN
CREATE(gPDFCreator);
IF ISCLEAR(gPDFCreatorError) THEN
CREATE(gPDFCreatorError);
lIntReportID :=REPORT::"Sales - Invoice";
lTxtFileDirectory :=FinvoiceSetup."Finvoice Invoice App. File";
gPDFCreatorError := gPDFCreator.cError;
IF gPDFCreator.cStart('/NoProcessingAtStartup',TRUE) = FALSE THEN
ERROR('Status: Error: ' + gPDFCreatorError.Description);
gPDFCreatorOption := gPDFCreator.cOptions;
gPDFCreatorOption.UseAutosave := 1;
gPDFCreatorOption.UseAutosaveDirectory := 1;
gPDFCreatorOption.AutosaveDirectory := lTxtFileDirectory;
gPDFCreatorOption.AutosaveFormat := 0;
gPDFCreatorOption.AutosaveFilename := iTxtFileName;
gPDFCreator.cOptions := gPDFCreatorOption;
gPDFCreator.cClearCache();
gTxtDefaultPrinter := gPDFCreator.cDefaultPrinter;
gPDFCreator.cDefaultPrinter := 'PDFCreator';
gPDFCreator.cPrinterStop := FALSE;
IF NOT DifferentFile THEN BEGIN
lRecSalesInvHead.INIT;
lRecSalesInvHead.RESET;
lRecSalesInvHead.SETFILTER(lRecSalesInvHead."No.","Sales Invoice Header".GETFILTER("Sales Invoice Header"."No."));
IF lRecSalesInvHead.FINDFIRST THEN
REPORT.RUNMODAL(lIntReportID,FALSE,TRUE,lRecSalesInvHead);
END ELSE BEGIN
lRecSalesInvHead.INIT;
lRecSalesInvHead.RESET;
lRecSalesInvHead.SETRANGE(lRecSalesInvHead."No.","Sales Invoice Header"."No.");
IF lRecSalesInvHead.FINDFIRST THEN
REPORT.RUNMODAL(lIntReportID,FALSE,TRUE,lRecSalesInvHead);
END;
gPDFCreator.cDefaultPrinter :=gTxtDefaultPrinter;
END;
Regards
Pushpraj
Pushpraj
0
Comments
-
Hi Pushpraj,
Does is work if you print just one invoice ?
If so I would suggest clearing the gPDFCreator variable.0 -
Do you make it right, it works too!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions