Multiple Reports Print to PDF using PDF CREATOR

nav_devpnav_devp Member Posts: 47
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.



  • Options
    vijay_gvijay_g Member Posts: 884
    it's depend on how many pages your each report printing and how much time you have assigned to sleep.
  • Options
    nav_devpnav_devp Member Posts: 47
    I have assigned SLEEP until the FILEEXISTS is TRUE, so if I'm printing report 1->10, only 4, 6 are missing but rest 1-3, and 7-10 are printed fine.
  • Options
    SogSog Member Posts: 1,023
    I think the fileexists = true might be the wrong approach when following scenario is true: PDFcreator first creates the file, and then updates it as it is printing the pages (like creating a .rar with winrar).
    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?
    |Pressing F1 is so much faster than opening your browser|
  • Options
    ara3nara3n Member Posts: 9,256
    I suggest in addition to use. SETSTAMP as well that will wait till PDFCreator has finished and the file can be modified.
    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.
    Ahmed Rashed Amini
    Independent Consultant/Developer

    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    John29John29 Member Posts: 3
    Hi, Sorry if this is too late for you, hopefully can help others.

    //You can terminate loops with a sleep using this command:
    //Which returns a boolean when successful.

    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
    UNTIL (((TIME - Time1) / 1000) >= tblSetup."pdf Timeout (Seconds)") OR
    (PDFCreator.cIsConverted = TRUE);

    //This ends a 1 second loop when the file exists
    FileFound := FALSE;
    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;
    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)");
Sign In or Register to comment.