PDF Creator batch processing problem
wochm
Member Posts: 26
Hi All,
I have a problem with PDF Creator for batch processing.
I have created a report and OnAfterGetRecord trigger calls a codeunit to generate a PDF file. PDF file is supposed to be created separately for each iteration.
Report code is as follows:
SendPDFReport is a codeunit variable processing PDF file using PDF Creator automation servers.
The problem I have is when a pdf file is being created for one record in the filter it works fine, but for more records it fails. In latter scenarion only for first record a pdf file is created.
Codeunit code is as follows:
Uncommented line
//PDFCreator.cIsConverted := FALSE;
hangs NAV or more accurately REPEAT ... UNTIL loop never ends for 2nd go. eReady event is not called.
Can you help me, please?
Regards,
Marcin
I have a problem with PDF Creator for batch processing.
I have created a report and OnAfterGetRecord trigger calls a codeunit to generate a PDF file. PDF file is supposed to be created separately for each iteration.
Report code is as follows:
OnAfterGetRecord=BEGIN
Cust.GET("Sell-to Customer No.");;
Cust.TESTFIELD("Invoice E-Mail");
SendPDFReport.SetParams(ReportNo, Cust."Invoice E-Mail", Text001);
SendPDFReport.SetSalesInv("Sales Invoice Header");
SendPDFReport.RUN;
END;
SendPDFReport is a codeunit variable processing PDF file using PDF Creator automation servers.
The problem I have is when a pdf file is being created for one record in the filter it works fine, but for more records it fails. In latter scenarion only for first record a pdf file is created.
Codeunit code is as follows:
OBJECT Codeunit 50002 Send PDF Report
{
OBJECT-PROPERTIES
{
Date=24/11/09;
Time=09:15:39;
Modified=Yes;
Version List=CH01201;
}
PROPERTIES
{
OnRun=BEGIN
GLSetup.GET;
GLSetup.TESTFIELD("PDF Creator Driver Name");
PDFFileName := STRSUBSTNO(SubjectTxt, SalesInvHeader."No.")
PDFDirectory := TEMPORARYPATH;
IF ISCLEAR(PDFCreator) THEN
CREATE(PDFCreator);
IF ISCLEAR(PDFCreatorError) THEN
CREATE(PDFCreatorError);
PDFCreatorError := PDFCreator.cError;
IF NOT PDFCreator.cStart('/NoProcessingAtStartup', TRUE) THEN
ERROR(Text002 + FORMAT(PDFCreatorError.Number) + ']: ' + PDFCreatorError.Description);
PDFCreatorOption := PDFCreator.cOptions;
PDFCreatorOption.UseAutosave := 1;
PDFCreatorOption.UseAutosaveDirectory := 1;
PDFCreatorOption.AutosaveDirectory := PDFDirectory;
PDFCreatorOption.AutosaveFormat := 0;
PDFCreatorOption.AutosaveFilename := PDFFileName;
PDFCreator.cOptions := PDFCreatorOption;
PDFCreator.cClearCache();
DefaultPrinter := PDFCreator.cDefaultPrinter;
PDFCreator.cDefaultPrinter := GLSetup."PDF Creator Driver Name";
PDFCreator.cPrinterStop := FALSE;
REPORT.RUNMODAL(ReportNo, FALSE, TRUE, SalesInvHeader)
//PDFCreator.cIsConverted := FALSE;
REPEAT
UNTIL PDFCreator.cIsConverted;
Mail.NewMessage(EMailAddress, '', STRSUBSTNO(SubjectTxt, SalesInvHeader."No."), '', PDFDirectory + PDFFileName + '.pdf', TRUE)
IF EXISTS(PDFDirectory + PDFFileName + '.pdf') THEN
IF ERASE(PDFDirectory + PDFFileName + '.pdf') THEN;
END;
}
CODE
{
VAR
GLSetup@1000000020 : Record 98;
SalesInvHeader@1000000011 : Record 112;
PDFCreator@1000000002 : Automation "{1CE9DC08-9FBC-45C6-8A7C-4FE1E208A613} 6.1:{FBAAB693-CD00-42DE-ADB1-C5E5CA03700D}:'PDFCreator'.clsPDFCreator" WITHEVENTS;
PDFCreatorOption@1000000001 : Automation "{1CE9DC08-9FBC-45C6-8A7C-4FE1E208A613} 6.1:{FCC886F6-E0DF-4302-8BE4-F8A8D9CB881C}:'PDFCreator'.clsPDFCreatorOptions";
PDFCreatorError@1000000000 : Automation "{1CE9DC08-9FBC-45C6-8A7C-4FE1E208A613} 6.1:{84D26557-2990-4B3E-A99F-C4DC1CB6C225}:'PDFCreator'.clsPDFCreatorError";
Text002@1000000005 : TextConst 'ENG=Startup Error[';
Text003@1000000004 : TextConst 'ENG=Error[';
Mail@1000000014 : Codeunit 397;
PDFDirectory@1000000009 : Text[1000];
PDFFileName@1000000008 : Text[250];
DefaultPrinter@1000000007 : Text[250];
EMailAddress@1000000015 : Text[50];
SubjectTxt@1000000006 : Text[30];
ReportNo@1000000003 : Integer;
PROCEDURE SetParams@1000000000(RepNo@1000000001 : Integer;EMail@1000000002 : Text[50];Subject@1000000003 : Text[30]);
BEGIN
ReportNo := RepNo;
EMailAddress := EMail;
SubjectTxt := Subject;
END;
PROCEDURE SetSalesInv@1000000001(VAR SalesInvHdr@1000000000 : Record 112);
BEGIN
SalesInvHeader.RESET;
SalesInvHeader.SETRANGE("No.", SalesInvHdr."No.");
SalesInvHeader.FINDFIRST;
END;
EVENT PDFCreator@1000000002::eReady@1();
BEGIN
PDFCreator.cPrinterStop := TRUE;
PDFCreator.cDefaultPrinter := DefaultPrinter;
PDFCreator.cClose();
END;
EVENT PDFCreator@1000000002::eError@2();
BEGIN
ERROR(Text003 + FORMAT(PDFCreatorError.Number) + ']: ' + PDFCreatorError.Description);
END;
BEGIN
END.
}
}
Uncommented line
//PDFCreator.cIsConverted := FALSE;
hangs NAV or more accurately REPEAT ... UNTIL loop never ends for 2nd go. eReady event is not called.
Can you help me, please?
Regards,
Marcin
0
Comments
-
Hi wochm,
maybe this will helpCust.TESTFIELD("Invoice E-Mail"); CLEAR(SendPDFReport); SendPDFReport.SetParams(ReportNo, Cust."Invoice E-Mail", Text001); SendPDFReport.SetSalesInv("Sales Invoice Header");0 -
Hi,
Thanks very much for your prompt response. I tried this but it did not help. But what is interesting I checked the same objects on Win XP (before I've run it on Vista) and on XP it works fine. Maybe the problem lies here.
Cheers,
Marcin0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 328 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