Merge PDF with Bullzip PDF

DavidJsDavidJs Member Posts: 9
Hi everyone!

I'm struggling with merging different PDF documents into one. I'm working with a NAV 17.
My code is almost the same as the example they use in their page, but the merge part.
While they use:
// Merge with other PDF files.
    pdfSettings.SetValue('MergeFile', mergeBeforeFileName + '|.|' + mergeAfterFileName);
I use for the path
i := 1;
rFilePath.SETRANGE(Path, PathParam);
rFilePath.SETRANGE("Is a file", TRUE);
IF rFilePath.FINDSET THEN BEGIN
  REPEAT
      FileNames[I] := PathParam + rFilePath.Name;
      i += 1;
    END;
  UNTIL rFilePath.NEXT = 0;

and for final merge:
  pdfSettings.SetValue('MergeFile', PDFFinalRoute + '|.|' + FileNames[i]);

but no file is created nor modified.
Am I missing something?
Is there a workaround?

Thanks in advance!

Best Answer

  • DavidJsDavidJs Member Posts: 9
    Answer ✓
    SOLVED

    In case anyone in the future has the same problem. You HAVE to print something to merge with.
    I couldn't use it as a tool to merge N existing pdfs. So I solved it by creating a white sheet report to merge in between the ones I wanted to merge.
    I hope someone finds that usefull!

Answers

  • ShaiHuludShaiHulud Member Posts: 228
    My guess is that you are missing the most important line:
    pdfSettings.WriteSettings(TRUE);
    
    The SetValue function only describes what BullZip should do, you have to WriteSettings to actually execute the instructions.

    As you're testing, you might also want to utilize the status file, just to make sure that everything goes fine.
        (before pdfSettings.WriteSettings(TRUE);)
        pdfSettings.SetValue('StatusFile', statusFileName);
        [..]
        [..]
        IF pdfUtil.WaitForFile(statusFileName, 20000)  THEN BEGIN
          // Check status file for errors.
          IF pdfUtil.ReadIniString(statusFileName, 'Status', 'Errors', '') <> '0' THEN BEGIN
            ERROR('Error creating PDF. ' + pdfUtil.ReadIniString(statusFileName, 'Status', 'MessageText', ''));
          END;
        END ELSE BEGIN
          // The timeout elapsed. Something is wrong.
          ERROR('Error creating ' + pdfFileName)
        END;
    
  • DavidJsDavidJs Member Posts: 9
    edited 2022-09-08
    I did indeed had the pdf.WriteSettings(true);

    Added this as you mention,
    ShaiHulud wrote: »
    As you're testing, you might also want to utilize the status file, just to make sure that everything goes fine.
        (before pdfSettings.WriteSettings(TRUE);)
        pdfSettings.SetValue('StatusFile', statusFileName);
        [..]
        [..]
        IF pdfUtil.WaitForFile(statusFileName, 20000)  THEN BEGIN
          // Check status file for errors.
          IF pdfUtil.ReadIniString(statusFileName, 'Status', 'Errors', '') <> '0' THEN BEGIN
            ERROR('Error creating PDF. ' + pdfUtil.ReadIniString(statusFileName, 'Status', 'MessageText', ''));
          END;
        END ELSE BEGIN
          // The timeout elapsed. Something is wrong.
          ERROR('Error creating ' + pdfFileName)
        END;
    
    but it seems like there is some error creating the file as i'm getting the "ELSE" error.

    I've been checking for the "ini" file to be created on the path file but it does not create, if this add any insight.
  • DavidJsDavidJs Member Posts: 9
    Answer ✓
    SOLVED

    In case anyone in the future has the same problem. You HAVE to print something to merge with.
    I couldn't use it as a tool to merge N existing pdfs. So I solved it by creating a white sheet report to merge in between the ones I wanted to merge.
    I hope someone finds that usefull!
Sign In or Register to comment.