Skip to main content
Post a question

Notifications

Community site session details

Community site session details

Session Id : FatQenA39E+4B60I6KWQ5v
Microsoft Dynamics NAV (Archived)

Adding another page on PDF file

Like (1) ShareShare
ReportReport
Posted on 6 Sep 2017 13:14:08 by

Greeting,

Is it possible to add another page on PDF file which is located on external path, when generating report.

Thanks

*This post is locked for comments

  • Boston Profile Picture
    4 on 08 Oct 2024 at 11:18:11
    Adding another page on PDF file
    Good advice. I'll have to give it a try.
  • Sarav Profile Picture
    437 on 03 Dec 2019 at 01:47:15
    RE: Adding another page on PDF file

    Hi,

    I tried the same approach. It's working well if the Pdf paths defined to ProcessStartInfo.Arguments is hardcoded like mentioned and I'm facing issue if I'm using it through variables. I believe there is some issue in the quotes.

    The following is the code which I used. Request your guidance on it.

    ProcessStartInfo := ProcessStartInfo.ProcessStartInfo('C:\Program Files (x86)\Metaist\pdfmerge\bin\pdfmerge.exe');

    ArgumentPath := ''+'-o "'+NewPDFFile+'" "'+ PDFFile1 +'" "'+PDFFile2+'"';

    ProcessStartInfo.Arguments := ArgumentPath;

    ProcessStartInfo.UseShellExecute := FALSE;

    ProcessStartInfo.CreateNoWindow := TRUE;

    ProcessStartInfo.WindowStyle := ProcessWindowStyle.Hidden;

    ProcessStartInfo.RedirectStandardOutput := TRUE;

    Process := Process.Process;

    Process.StartInfo(ProcessStartInfo);

    Process.Start;

  • Verified answer
    Suresh Kulla Profile Picture
    46,159 on 15 Sep 2017 at 00:36:47
    RE: Adding another page on PDF file

    Below is the code which will merge file1 and file2 as out.pdf 

    These are variable declarations

    ProcessStartInfo - DotNet - System.Diagnostics.ProcessStartInfo.'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

    Process  - DotNet - System.Diagnostics.Process.'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'


    ProcessStartInfo := ProcessStartInfo.ProcessStartInfo('C:\Program Files (x86)\Metaist\pdfmerge\bin\pdfmerge.exe');
    ProcessStartInfo.Arguments := '-o "c:\temp\out.pdf" "C:\Temp\file1.pdf" "C:\Temp\file2.pdf"';
    ProcessStartInfo.UseShellExecute := FALSE;
    ProcessStartInfo.CreateNoWindow := TRUE;
    ProcessStartInfo.RedirectStandardOutput := TRUE;
    Process := Process.Process;
    Process.StartInfo(ProcessStartInfo);
    Process.Start;

  • Suggested answer
    Suresh Kulla Profile Picture
    46,159 on 14 Sep 2017 at 18:26:39
    RE: Adding another page on PDF file

    Please try to use processInfo instead of Shell to run the program. For example please check below

    community.dynamics.com/.../executing-external-programs

  • Community Member Profile Picture
    on 14 Sep 2017 at 08:38:55
    RE: Adding another page on PDF file

    greska.png

  • Suggested answer
    Suresh Kulla Profile Picture
    46,159 on 13 Sep 2017 at 16:59:20
    RE: Adding another page on PDF file

    What error are you getting using that application ?

  • Community Member Profile Picture
    on 13 Sep 2017 at 14:47:58
    RE: Adding another page on PDF file

    Emp.RESET;

    Emp.SETRANGE("Employee No.",No);

    Emp.SETRANGE(Active,TRUE);

    IF Emp.FIND('-') THEN

     REPEAT

            CLEAR(R_Contract);

            CLEAR(FileManagement);

            R_Contract.SetParam(No,TODAY);

            R_Contract.SETTABLEVIEW(Emp);

            //filename:='C:\Temp\PayList-'+T_Employee."First Name"+' '+T_Employee."Last Name"+'.pdf';

           // filename:='\\HR\c\NAV2016\Platna Lista-'+Emp."First Name"+' '+Emp."Last Name"+'.pdf';

           filename:='C:\Temp\'+Emp."Employee No."+'.pdf';

           filename2:='C:\Temp\1031.pdf';

            R_Contract.SAVEASPDF(filename);

            FileManagement.DownloadToFile(filename,filename);

            IFi:='"'+filename+'"'+',';

            OFi:='"'+filename2+'"';

             MergePDFFiles(IFi+OFi,'C:\Temp\Result.pdf');

     UNTIL Emp.NEXT=0;

    CLEAR(WshShell);

    HRSetup.GET;

    CMD_LineTxt:=STRSUBSTNO('%1 output=%2 input=%3',HRSetup."PDF Merge Tool",OutputFileName,InputFileName);

    dumyInt:=0;

    runMod:=FALSE;

    CREATE(WshShell,FALSE,TRUE);

    WshShell.Run(CMD_LineTxt);

    SLEEP(3000);

    CLEAR(WshShell);

    This is code i used but it doesn't work. I have problem with pdfmerge application. If you could propose some application that will resolve my problem.

  • Verified answer
    Suresh Kulla Profile Picture
    46,159 on 06 Sep 2017 at 16:36:40
    RE: Adding another page on PDF file

    I am not sure if you can print that but you can use an utility called PDF merge to merge two files after you saving your report into PDF

    github.com/.../pdfmerge

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,333 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,278 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans
Loading complete