Hi All,
I'm using PDF creatot to print few NAV reports back to back, problem is if I'm printing 10 reports and saving them at predefined place, actually only 6-7 files gets printed and rest are LOSS, not sure why this is happening.
I have put the code in NAV that before moving to print the next report, make sure previous report is printed and saved(using SLEEP command and FILEEXISTS). But no luck.
Has anyone come across this problem, is there any trigger in PDF CREATOR which confirms that report is printed and saved , using which I can determine when to move on to next report printing or any workaround?
Each report that I'm running can run upto 1 page to 1200 pages.
Please help.
Regards,
0
Comments
it's depend on how many pages your each report printing and how much time you have assigned to sleep.
You should also check if your filenames for each report are unique.
Is it possible to have the report printed in one place, and when pdf-creator finishes, it moves it to the correct folder?
|To-Increase|
SETSTAmp will try to change the time stamp for a file and if the file is still being written to, it will return false so you can wait till PDFCreator finishes and NAV can change the time stamp.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
//You can terminate loops with a sleep using this command:
//PDFCreator.cIsConverted
//Which returns a boolean when successful.
//Regards,
Actually, found a better way:
Sample Code working on site:
Time1 := TIME;
//this ends a 1 second sleep loop when pdf creator has initialised (not finished) a file
REPEAT
SLEEP(1000);
UNTIL (((TIME - Time1) / 1000) >= tblSetup."pdf Timeout (Seconds)") OR
(PDFCreator.cIsConverted = TRUE);
//This ends a 1 second loop when the file exists
FileFound := FALSE;
REPEAT
SLEEP(1000);
IF EXISTS(PDFDirectory + PDFFileName) THEN
FileFound := TRUE;
UNTIL (((TIME - Time1) / 1000) >= tblSetup."pdf Timeout (Seconds)") OR FileFound;
IF NOT FileFound THEN
ERROR('Sorry!\The PDF convertor program failed to produce the required file %1\'+
'Within the specified timout interval',PDFDirectory + PDFFileName);
//This ends a 1 second loop when the pdf printer buffer is lowered by 1
PrintJobs := PDFCreator.cCountOfPrintjobs;
i := 0;
REPEAT
SLEEP(1000);
i += 1;
UNTIL (i >= tblPurchSetup."pdf Timeout (Seconds)") OR (PDFCreator.cCountOfPrintjobs < PrintJobs);
IF NOT EXISTS(PDFDirectory + PDFFileName) THEN
ERROR('Sorry!\The PDF file creation program has failed within the timeout of %1 seconds',
tblPurchSetup."pdf Timeout (Seconds)");