Merge PDF-Files

stiastastiasta Posts: 106Member
edited 2011-06-07 in NAV Three Tier
Hello!
I was wondering if anyone had an example of how to merge pdf-files that are created by using SAVEASPDF function?

I have tried this.
Filenames[1] := 'C:\Temp\1.pdf';
Filenames[2] := 'C:\Temp\2.pdf';
Filenames[3] := 'C:\Temp\3.pdf';

SalesInvoiceReport.SAVEASPDF(Filenames[1]);
DyconTimerReport.SAVEASPDF(Filenames[2]);
DyconUtgiftReport.SAVEASPDF(Filenames[3]);

IF ISCLEAR(DyconPDFMerger) THEN
CREATE(DyconPDFMerger);

tempText := DyconPDFMerger.MergeFiles('C:\Temp\output.pdf', 'C:\Temp\', '1.pdf;2.pdf;3.pdf');
(The code above forces the role based client to disconnect.)

I have also tried using BioPDF:
IF ISCLEAR(BioPDF) THEN
  CREATE(BioPDF);

BioPDF.Init;
BioPDF.LoadSettings;
RunOnceFile := BioPDF.GetSettingsFileName(TRUE);
BioPDF.SetValue('Output','c:\temp\testoutput.pdf');
BioPDF.SetValue('Showsettings', 'never');
BioPDF.SetValue('ShowPDF', 'no');
BioPDF.SetValue('ShowProgress', 'no');
BioPDF.SetValue('ShowProgressFinished', 'no');
BioPDF.SetValue('SuppressErrors', 'yes');
BioPDF.SetValue('ConfirmOverwrite', 'no');

BioPDF.SetValue('MergeFile', Filenames[1] + '|' + Filenames[2] + '|' + Filenames[3]);

BioPDF.WriteSettings(TRUE);

TimeOut := 0;
WHILE EXISTS(RunOnceFile) AND (TimeOut < 10) DO BEGIN
SLEEP(1000);
TimeOut := TimeOut + 1;
END;


Any tips?
«1

Comments

  • BeliasBelias Posts: 2,993Member
    edited 2011-06-01
    some questions:
    1. where did you put the code?
    2. does it work in classic?
    2a. if so, is the a biopdf (or whatever) installed in the same place of nav server? (you know, automations are instatiated on nav server, unless you specify TRUE parameter of the CREATE function) unless you specify the TRUE parameter as the third one. To check this out, try to do
    // wrong code deleted
    
    CREATE(biopdf,FALSE,TRUE);
    
    instead of
    CREATE(biopdf);
    
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • mihail_kolevmihail_kolev Posts: 379Member
    Belias wrote:
    CREATE(biopdf,TRUE);
    
    did you mean
    CREATE(biopdf,FALSE,ISSERVICETIER)
    
    -Mihail- [MCTS]
  • BeliasBelias Posts: 2,993Member
    ...did you mean...
    yup, sorry...i forgot the second parameter :whistle:
    i edited my previous message...
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • stiastastiasta Posts: 106Member
    Hello again!
    I have tried what you said. Good suggestion.
    But, the merged pdf will still not write and save. I have checked the server and the client and it is not in either of the places.
    I have tried to start the automation on both computers aswell. (create(bla, false, false), and create(bla, false, true).

    Here is all of the code i am trying
    
    Filenames[1] := 'C:\Temp\1.pdf';
    Filenames[2] := 'C:\Temp\2.pdf';
    Filenames[3] := 'C:\Temp\3.pdf';
    
    SalesInvoiceReport.SAVEASPDF(Filenames[1]);
    DyconTimerReport.SAVEASPDF(Filenames[2]);
    DyconUtgiftReport.SAVEASPDF(Filenames[3]);
    
    //IF ISCLEAR(DyconPDFMerger) THEN
    //CREATE(DyconPDFMerger);
    
    //tempText := DyconPDFMerger.MergeFiles('C:\Temp\output.pdf', 'C:\Temp\', '1.pdf;2.pdf;3.pdf');
    
    
    {CREATE(wShExec);
    wShExec.Run('c:\PdfDocuments\DyconPDFMergerCMD.exe ' +'c:\temp\output.pdf'+' '+ Filenames[1] + ' ' +
                             Filenames[2] + ' ' + Filenames[3]);
    CLEAR(wShExec);
    //SHELL('c:\PdfDocuments\DyconPDFMergerCMD.exe', Filenames[1], Filenames[2], Filenames[3]);
    
    }
    IF ISCLEAR(BioPDF) THEN
      CREATE(BioPDF, FALSE, TRUE);
    
    BioPDF.Init;
    BioPDF.LoadSettings;
    RunOnceFile := BioPDF.GetSettingsFileName(TRUE);
    BioPDF.SetValue('Output','c:\temp\testoutput.pdf');
    BioPDF.SetValue('Showsettings', 'never');
    BioPDF.SetValue('ShowPDF', 'no');
    BioPDF.SetValue('ShowProgress', 'no');
    BioPDF.SetValue('ShowProgressFinished', 'no');
    BioPDF.SetValue('SuppressErrors', 'yes');
    BioPDF.SetValue('ConfirmOverwrite', 'no');
    
    BioPDF.SetValue('MergeFile', Filenames[1] + '|' + Filenames[2] + '|' + Filenames[3]);
    
    BioPDF.WriteSettings(TRUE);
    
    
    
    TimeOut := 0;
    WHILE EXISTS(RunOnceFile) AND (TimeOut < 10) DO BEGIN
    SLEEP(1000);
    TimeOut := TimeOut + 1;
    END;
    
  • BeliasBelias Posts: 2,993Member
    i think the file has been written on the NAV SERVER machine on "c:\temp\output.pdf".
    Check out mibuso about how to handle files in role tailored client, i think that this is your issue
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • stiastastiasta Posts: 106Member
    There has not been written to the Nav Server in C:\Temp The only file i get outputted is c:\temp\1.pdf which is the first report. I have tested by creating two more pdfs called 2.pdf and 3.pdf to see if the problem was that there was only 1 file. But no, it will still not merge into testoutput.pdf.
  • BeliasBelias Posts: 2,993Member
    SAVEASPDF help online:
    The FileName parameter specifies a location on the computer running Microsoft Dynamics NAV Server
    my WAG is that you create the pdfs on the server and then try to merge them on the client (where they does not exist) :-k
    you should DOWNLOAD the pdfs from nav server and then merge them
    OR
    install the biopdf on the server and instantiate it on the server (a plain CREATE(biopdf) should be enough). In this way you can save the 3 pdfs to merge on server, merge them on the server and then download the result on the client (this is the best option in my opinion: in this way you install the biopdf only on the server machine instead of on all the clients; moreover you thin the network traffic)
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • stiastastiasta Posts: 106Member
    The BioPDF is installed on the server and the automation create command is set to CREATE(BioPDF, FALSE, FALSE)
    But still nothing.
  • stiastastiasta Posts: 106Member
    I did also try a plain create(BioPDF)
  • BeliasBelias Posts: 2,993Member
    summary:
    1. triple SAVEASPDF (create files on server) --> how many files does it create? just one of three?!
    2. create(biopdf) on server
    3. merge files on server on specified path on the server (does the path exist?)
    4. the merged pdf is NOT created on the server (or is just one file created or whatever?)

    if you've done everything correct, i think that there's some issue in the automation management, but here i can't help: never used it
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • stiastastiasta Posts: 106Member
    1. This is irrelevant since it does not have anything with the Pdf merging. I have commented these out and created 3 static files in the filepath c:\Temp that is inserted into bioPDF
    2. done
    3. Path does exist
    4. The merge is not created on the server.

    So i think this problem lies with the BioPDF automation server... I am not sure that it runs at all, when there is no report that is printing.
  • BeliasBelias Posts: 2,993Member
    ok, you can try to run the biopdf manually on the three files and see what happens: if it works, check out the management of the automation :-k or search online "biopdf navision" or something similar (but i think you've already done both these things)
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • mihail_kolevmihail_kolev Posts: 379Member
    stiasta wrote:
    ...
    IF ISCLEAR(DyconPDFMerger) THEN
    CREATE(DyconPDFMerger);
    
    tempText := DyconPDFMerger.MergeFiles('C:\Temp\output.pdf', 'C:\Temp\', '1.pdf;2.pdf;3.pdf');
    ...
    

    did you try the DyconPDFMerger again with correct CREATE parameters
    ...
    IF ISCLEAR(DyconPDFMerger) THEN
    CREATE(DyconPDFMerger,FALSE,ISSERVICETIER);
    
    tempText := DyconPDFMerger.MergeFiles('C:\Temp\output.pdf', 'C:\Temp\', '1.pdf;2.pdf;3.pdf');
    ...
    

    I've never merged pdfs and never heard about these pdf mergers... Just shoot in the dark :)
    -Mihail- [MCTS]
  • stiastastiasta Posts: 106Member
    I tried it and got this error message:
    1.png 6.9K
  • mihail_kolevmihail_kolev Posts: 379Member
    The DyconPDFMerger is not installed on the client machine. Install it and try again.
    -Mihail- [MCTS]
  • stiastastiasta Posts: 106Member
    It is installed.
    I am running the role based client from the same machine as the server now.
    I can try running it from a seperate computer.... trying it now
  • stiastastiasta Posts: 106Member
    a different error occurs.
    2.png 19.8K
  • mihail_kolevmihail_kolev Posts: 379Member
    ok, this error (first one) is thrown by CREATE and for some reason it can not create the DyconPDFMerger.Main - are you sure you should use the .Main class?
    -Mihail- [MCTS]
  • stiastastiasta Posts: 106Member
    Its the only class :) I made the automation server myself. but i have a seperate topic relating to that :)
  • mihail_kolevmihail_kolev Posts: 379Member
    did you try to release the automation for x86 platform. NAS and RTC are x86
    -Mihail- [MCTS]
  • stiastastiasta Posts: 106Member
    worked! :O
    I had already tried the x86 but without restarting nav server and without the ISSERVICETIER command.
  • mihail_kolevmihail_kolev Posts: 379Member
    stiasta wrote:
    worked! :O
    I had already tried the x86 but without restarting nav server and without the ISSERVICETIER command.

    Great :) , Just add the [SOLVED] check to your first post :)
    -Mihail- [MCTS]
  • stiastastiasta Posts: 106Member
    Thank you so much for your help mihail_kolev and Belias. As a reward you can have my pdfmerger if you want :):) send me a PM to ask about it and i will send it to you.

    The problem with BioPDF is still a little annoying. But, no need to do anything about it now.
  • mihail_kolevmihail_kolev Posts: 379Member
    stiasta wrote:
    Thank you so much for your help mihail_kolev and Belias. As a reward you can have my pdfmerger if you want :):) send me a PM to ask about it and i will send it to you.

    The problem with BioPDF is still a little annoying. But, no need to do anything about it now.

    You've shared the pdf merger already - viewtopic.php?f=32&t=47806 , but that's why we are here - sharing knowledge and help each other :)
    -Mihail- [MCTS]
  • BeliasBelias Posts: 2,993Member
    that's why we are here - sharing knowledge and help each other
    you can say it twice!
    our reward is that you (or someone else in the forum) will spend a pair of minutes of their time in order to help us with our problems! :wink:
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • stiastastiasta Posts: 106Member
    Another problem occurred...
    I am able to run the Automation server from the server itself. BUT, when i try it from a client outside the server it will not work. I think it is the reoccurring problem of setting permissions for windows 2008 server :S
    any idea?
  • mihail_kolevmihail_kolev Posts: 379Member
    It will work, but you need to install the automation on client machines. PDF files will be saved on the service machine, so the filename should look like "\\service_machine\C$\temp", not "C:\temp". And the folder should be shared
    -Mihail- [MCTS]
  • stiastastiasta Posts: 106Member
    for documentation here is the error screencap

    "Systemet finner ikke angitt fil..." = System is unable to find given file.
    1.jpg 29.3K
  • BeliasBelias Posts: 2,993Member
    as me and mihail said, the saveaspdf function saves the 3 pdfs on the server. If you instantiate the automation on the client machine it won't see the files. BTW i think that if you instantiate it on the server, i think it will see the files w/o problems. Otherwise use the path said by mihail or use DOWNLOAD instruction to copy the files on the client (but as i said before, i would prefer the "do everything on server and then download the merged file" solution, if it works.
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • mihail_kolevmihail_kolev Posts: 379Member
    looks like some other libraries are not installed. Is the .NET version on the client up to date?
    -Mihail- [MCTS]
Sign In or Register to comment.