How to save Navision Reports as PDF

1235710

Comments

  • ara3nara3n Member Posts: 9,255
    Something Else I would try also is open PdfCreator Printer. Click on File->Option and resetall button
    If things go horribly awry, and you lose the ability to choose options when printing to PDFCreator, just go to the above, click on Printer\Settings, and click the big "Reset all Settings" button (shown below). That will restore you to the defaults, and you'll be good to start playing around again
    .

    http://www.excelguru.ca/node/33
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • rnunesrnunes Member Posts: 9
    yes this is very strange indeed. I've tried to reset all settings, and no luck, then i even installed the latest version of pdfcreator and nothing... I really don't know what's the problem, but the thing is that the other options like autosave doesn't work right either.

    Regards
  • ara3nara3n Member Posts: 9,255
    Did you change the automation variable to latest version in your code?

    you can also try Bullzip.

    http://mibuso.com/blogs/ara3n/2008/08/
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • rnunesrnunes Member Posts: 9
    yes i did... i'll try bullzip.
  • rnunesrnunes Member Posts: 9
    Solved... with bullzip works just fine.

    Thanks
  • ara3nara3n Member Posts: 9,255
    that's great.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • fufikkfufikk Member Posts: 104
    The 0.9.6 version of PdfCreator seems to solve the cClose function hanging behaviour. I installed this version today and it seems to be working faster, properly closing and the eReady event fires correctly.
  • ara3nara3n Member Posts: 9,255
    Thanks for the update. I'm sure people will upgrade to the latest one.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • NinlilNinlil Member Posts: 20
    Just looked into the functions in the just-released NAV 2009 W1.

    There is a REPORT.SAVEASPDF(ReportID...) function !!! \:D/

    (also contains SAVEASEXCEL and SAVEASXML)... Haven't tried them yet thou.
  • ara3nara3n Member Posts: 9,255
    Yes, it's a nice feature that was added but it only works on service tier.
    and on RTC client.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • nightrodnightrod Member Posts: 68
    Hi Rashed,

    i am using bullzip now.
    on an xp machine it is working great now.
    on a vista machine the code is run but there is no file.
    What can it be?

    the code i use is this:
    Best regards,
    Rod.
    [-o<
    recSalesHeader.SETRANGE("Document Type", Rec."Document Type");
    recSalesHeader.SETRANGE("No.", Rec."No.");

    IF ISCLEAR(BullZipPDF) THEN
    CREATE(BullZipPDF);

    ReportID := REPORT::"Order Confirmation";
    FileDirectory := 'C:\';
    FileName :='test.pdf';


    Object.GET(Object.Type::Report,'',ReportID);

    BullZipPDF.Init;
    BullZipPDF.LoadSettings;
    RunOnceFile := BullZipPDF.GetSettingsFileName(TRUE);
    BullZipPDF.SetValue('Output',FileDirectory+FileName);
    BullZipPDF.SetValue('Showsettings', 'never');
    BullZipPDF.SetValue('ShowPDF', 'no');
    BullZipPDF.SetValue('ShowProgress', 'no');
    BullZipPDF.SetValue('ShowProgressFinished', 'no');
    BullZipPDF.SetValue('SuppressErrors', 'yes');
    BullZipPDF.SetValue('ConfirmOverwrite', 'no');
    BullZipPDF.WriteSettings(TRUE);
    REPORT.RUNMODAL(ReportID,FALSE,FALSE,recSalesHeader);

    TimeOut := 0;
    WHILE EXISTS(RunOnceFile) AND (TimeOut < 10) DO BEGIN
    SLEEP(1000);
    TimeOut := TimeOut + 1;
    END;
  • ShinigamiShinigami Member Posts: 2
    Hi all,

    and thanks to all for this post! You all helped me a lot in my work (ara3n you're the best =D> )

    After a lot of try, i successfully used pdfCreator 0.9.6 on Vista :x

    the worst problem? you can't save your pdf in "c:\" !!!
    if you try, pdf creator seems to work in background but the file is simply not created, without warnings or message.
    I've just tried to change the directory in "d:\" and it works perfectly...

    I hope i can help someone to save a lot of time testing!
    Lend me your strength and i'll give you mine
  • dgroeserdgroeser Member Posts: 39
    When i start the PDF Creation the the CPU is 98 % and not stop the Report, navision hang up, when i stop the prozess the got follow Message
    coud not invoike the member cClose. The OLE control or Automation server returned an unknown error code

    Here is my Code
    IF ISCLEAR(PDFCreator) THEN
      CREATE(PDFCreator);
    IF ISCLEAR(PDFCreatorError) THEN
      CREATE(PDFCreatorError);
    
    FileDirectory := 'C:\';
    FileName := 'example.pdf';
    
    PDFCreatorError := PDFCreator.cError;
    
    IF PDFCreator.cStart('/NoProcessingAtStartup',TRUE) = FALSE THEN
         ERROR('Status: Error[' + FORMAT(PDFCreatorError.Number) + ']: ' + PDFCreatorError.Description);
    
    PDFCreatorOption :=  PDFCreator.cOptions;
    
    PDFCreatorOption.UseAutosave := 1;
    PDFCreatorOption.UseAutosaveDirectory := 1;
    PDFCreatorOption.AutosaveDirectory := FileDirectory;
    PDFCreatorOption.AutosaveFormat := 0;                       //PDF file, you can also save in other formats
    PDFCreatorOption.AutosaveFilename := FileName;
    
    PDFCreator.cOptions := PDFCreatorOption;
    PDFCreator.cClearCache();
    DefaultPrinter := PDFCreator.cDefaultPrinter;
    PDFCreator.cDefaultPrinter := 'PDFCreator';
    PDFCreator.cPrinterStop := FALSE;
    
    
    Inv.SETRANGE("No.",'08-400002');
    REPORT.RUNMODAL(REPORT::"Sales - Invoice",FALSE,TRUE,Inv);
    
    WHILE NOT EXISTS(FileDirectory + FileName) DO;
    
    PDFCreator.cPrinterStop := TRUE;
    PDFCreator.cDefaultPrinter := DefaultPrinter;
    //PDFCreator.cCloseRunningSession;
    PDFCreator.cClose();
    
    CLEAR(PDFCreator);
    CLEAR(PDFCreatorOption);
    CLEAR(PDFCreatorError);
    
  • jordi79jordi79 Member Posts: 272
    Hi,

    I am using Rashed's code to print e.g. Invoices, and modify the code further to send these invoices as email to customers.

    The problem I have is at saving the files to PDF. Apparently, the results of the pdf save is not consistent. Sometimes, all the invoices are saved as PDF, sometimes not all the invoices are saved as PDF. I found out that when the batch job is run, and if NAV loses focus (e.g. If you miminise nav, and do other things while the batch job is running) then not all the pdf files will be saved.

    Initially, in my development, I added progress bars to update the status of the pdf save operation, but I found out that if dialog boxes are implemented, somehow, PDFcreator also loses focus, and it sometimes run into errors.

    Is anybody having similar problems as what I am facing? I am beginning to think that using PDFcreator is not such a good solution after all, and looking into other alternatives.
  • ara3nara3n Member Posts: 9,255
    you can also try Bullzip.

    http://mibuso.com/blogs/ara3n/2008/08/
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • ObiWanObiWan Member Posts: 21
    I have also experienced misc problems using PDFCreator. I used it in an WebPortal for printing Invoices and Cr.Memos, then hyperlink the saved PDF document.
    (Sometimes or often there were no pdf created at all...)
    I thought maybe the problem was print queues, so I also implemented Rashed Bullzip solution so that the NAS is alternating using the 2 diff
    printers. The solutions is now somewhat more stable.

    I would recomend you to use the Bullzip solution, thanks to Rashed for this one =D>

    Best regards
    ObiWan
  • jordi79jordi79 Member Posts: 272
    Hi,

    I have found the reason for the erratic behaviour with PDFcreator. In PDFCreator if we use the following statement:

    REPEAT
    SLEEP(1000);
    WaitTime += 1000;
    IF WaitTime = 15000 THEN
    ERROR('Timeout error while waiting for PDFCreator.cIsConverted!');
    UNTIL PDFCreator.cIsConverted;


    to check for completion of PDFcreation, you have to initialise PDFCreator.cIsConverted := FALSE. Else, somehow, the property PDFCreator.cIsConverted will always retain the values from the last run. Even if you have executed CLEAR(PDFcreator). I have run several tests with 100++ pdf creations, and the results seem to be consistent now.
  • ara3nara3n Member Posts: 9,255
    That is good to info to share.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • theisgrouptheisgroup Member Posts: 2
    What if you cant set the default print to bull zip (Terminal servers)?
  • ara3nara3n Member Posts: 9,255
    then insert a record into printer selection for your report to print the the printer you want it to.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • theisgrouptheisgroup Member Posts: 2
    What would be optimal is to setup the code to use the particular printer for the PDF purpose is that possible?
  • ara3nara3n Member Posts: 9,255
    mgm wrote:
    Thanx Rashed,

    What a SERVICE!

    This is what I added to make Bullzip default printer.
    IF NOT lPrinterSelection.GET('',lReportID) THEN BEGIN
      lPrinterSelection.INIT;
      lPrinterSelection."Report ID" := lReportID;
      lPrinterSelection."Printer Name" := 'Bullzip PDF Printer';
      lPrinterSelection.INSERT;
    END;
    

    Works great!
    Thanx again.

    Maarten

    Here is the code.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • EL_TORRESEL_TORRES Member Posts: 4
    How can I Close the PDFCreator Process because I used PDFCreato.cClose() and only close the PDF Monitor and when it happens and if I run again the code can't creat the file. Here's my code: thanks


    Window.OPEN('En proceso ...');
    WindowIsOpen := TRUE;
    IF _ArchivoPDF = '' THEN
    ERROR('De un nombre al archivo');

    IF Objeto.GET(Objeto.Tipo::Report,'',_ReportID) THEN
    BEGIN

    CLEAR(PDFCreator);
    CREATE(PDFCreator);

    PDFCreator.cStart();

    //***
    CLEAR(PDFCreatorOptions);
    CREATE(PDFCreatorOptions);
    //***

    CLEAR(PDFCreatorError);
    CREATE(PDFCreatorError);

    IF EXISTS(_Directorio + _ArchivoPDF + '.pdf') THEN
    BEGIN
    ERASE(_Directorio + _ArchivoPDF + '.pdf');
    END;

    PDFCreatorOptions := PDFCreator.cOptions;

    ReadyState := 0;
    //Defaultprinter := PDFCreator.cDefaultPrinter;
    PDFCreator.cDefaultPrinter := 'PDFCreator';
    PDFCreatorOptions.UseAutosave := 1;
    PDFCreatorOptions.UseAutosaveDirectory := 1;
    PDFCreatorOptions.AutosaveFormat := 0; //Formato PDF
    PDFCreatorOptions.AutosaveDirectory := _Directorio;
    PDFCreatorOptions.AutosaveFilename := _ArchivoPDF;
    //PDFCreator.cOptions:=PDFCreatorOptions;
    PDFCreator.cSaveOptions(PDFCreatorOptions);
    PDFCreator.cClearCache();
    PDFCreator.cPrinterStop := FALSE;

    Filename := _Directorio + _ArchivoPDF + '.pdf';
    PDFCreatorError := PDFCreator.cError;

    IF ObjetoTabla.GET(ObjetoTabla.Tipo::Table,'',_TablaID) THEN
    BEGIN
    IF FORMAT(ObjetoTabla.Nombre)='Cab. compra' THEN
    BEGIN
    Cabcompra.RESET;
    Cabcompra.SETFILTER(Cabcompra."Nº",No);
    Cabcompra.SETFILTER(Cabcompra."Tipo documento",'Pedido');
    IF Cabcompra.FIND('-') THEN
    REPORT.RUNMODAL(_ReportID,FALSE,TRUE,Cabcompra);
    END;
    END;

    PDFCreator.cClearCache();
    PDFCreatorOptions.SaveFilename(Filename);
    //PDFCreator.cOptions :=PDFCreatorOptions;

    PDFCreator.cClose();
    SLEEP(200);

    //CLEAR(PDFCreatorOptions);
    CLEAR(PDFCreator);
    Window.CLOSE;
    END;
  • ara3nara3n Member Posts: 9,255
    you need to wait fore the pdf file to be created, then close it. there are multiple examples for this. on this thread.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • vios15vios15 Member Posts: 43
    Hi,

    I have downloaded PDFCreator v 0.9.7 and copied Object Form 50100 Example Report to PDF Files.

    But encountered an error while compiling "Could not load the selected type Library."

    I am testing the PDF capabilities at the moment.

    Could you help?
  • vios15vios15 Member Posts: 43
    Hi,

    I have solved the problem by replacing automation at the C/AL Global

    Thanks
  • ara3nara3n Member Posts: 9,255
    Yes, the automation variable in the form is from older version of PDF Creator. You need to reselect the global variable.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • dgroeserdgroeser Member Posts: 39
    Have you always yet the Problem with hanging in the 0.9.7, if it start cClose() in vista?
  • gonzy1981gonzy1981 Member Posts: 156
    I've a ask:

    If i want to create a pdf and after i want to print the same, do you know as to do it.
    I'm trying to do this, but it create a pdf but doesn't print.


    IF ISCLEAR(PDFCreator) THEN
    CREATE(PDFCreator);
    IF ISCLEAR(PDFCreatorError) THEN
    CREATE(PDFCreatorError);


    PDFCreatorError := PDFCreator.cError;
    IF PDFCreator.cStart('/NoProcessingAtStartup',TRUE) = FALSE THEN
    ERROR('Status: Error: ' + PDFCreatorError.Description);
    PDFCreatorOption := PDFCreator.cOptions;
    PDFCreatorOption.UseAutosave := 1;
    PDFCreatorOption.UseAutosaveDirectory := 1;
    PDFCreatorOption.AutosaveDirectory := Route;
    PDFCreatorOption.AutosaveFormat := 0; PDFCreatorOption.AutosaveFilename := FileName;
    PDFCreator.cOptions := PDFCreatorOption;
    PDFCreator.cClearCache();
    DefaultPrinter := PDFCreator.cDefaultPrinter;
    PDFCreator.cDefaultPrinter := 'PDFCreator';
    PDFCreator.cPrinterStop := FALSE;

    //Here i create a pdf
    REPORT.RUN(ReportSelection."Report ID",FALSE,FALSE,SalesInvHeader);

    //And here i want to print
    CLEAR(PDFCreator);
    CLEAR(PDFCreatorError);
    REPORT.RUN(ReportSelection."Report ID",FALSE,FALSE,SalesInvHeader);

    Do you know what is the problem??
    Thanks
  • mohana_cse06mohana_cse06 Member Posts: 5,503
    Have u tried REPORT.RUN(ReportSelection."Report ID",FALSE,True,SalesInvHeader);
Sign In or Register to comment.