How to save Navision Reports as PDF

1468910

Comments

  • gonzy1981gonzy1981 Member Posts: 156
    The problem now is when i do this:
    REPORT.RUN(ReportSelection."Report ID",False,True,SalesInvHeader);
    then the Request Form is activate.

    If i do this:
    REPORT.RUN(ReportSelection."Report ID",True,True,SalesInvHeader);

    Then the Request Form isn't activate but the default printer is changed to PdfCreator and then there isn't a print.

    In in the PdfCreator i don't see the print.
  • dgroeserdgroeser Member Posts: 39
    Checked with RunModal?
  • gonzy1981gonzy1981 Member Posts: 156
    I'm using PdfCreator and i do this:

    PDFCreatorOption := PDFCreator.cOptions;
    PDFCreatorOption.UseAutosave := 1;
    PDFCreatorOption.UseAutosaveDirectory := 1;
    PDFCreatorOption.AutosaveDirectory := FileDirectory;
    PDFCreatorOption.AutosaveFormat := 0;
    PDFCreatorOption.AutosaveFilename := FileName;
    PDFCreator.cOptions := PDFCreatorOption;
    PDFCreator.cClearCache();
    DefaultPrinter := PDFCreator.cDefaultPrinter;
    PDFCreator.cDefaultPrinter := 'PDFCreator';

    PDFCreator.cPrinterStop := FALSE;

    REPORT.RUNMODAL(ReportID,FALSE,TRUE);

    But my problem is that my Default printer is changed to PdfCreator printer, do you know to change again in code to my old default printer.
  • ara3nara3n Member Posts: 9,256
    After PDFCreator finishes you set it back this way.


    PDFCreator.cDefaultPrinter := DefaultPrinter;
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • gonzy1981gonzy1981 Member Posts: 156
    Thanks, it's going ok.
  • ara3nara3n Member Posts: 9,256
    Just OK? not great?
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • gonzy1981gonzy1981 Member Posts: 156
    It's going great.
    :)
  • gonzy1981gonzy1981 Member Posts: 156
    Sorry, but i've a new problem with PdfCreator

    I'm doing this: I want to generate as pdf's as invoices and send them by e-mail

    .
    .
    REPEAT
    SetPdf;
    Report.RUN(206,FALSE,TRUE,SalesInvoiceHeader);
    IF (NOT EXISTS(MyFile)) AND (CONT < 5) THEN BEGIN
    SLEEP(3000);
    CONT := CONT + 1;
    END;
    IF EXISTS(MyFile) THEN
    SendMail;
    ClearMyPdf;
    UNTIL SalesInvoiceHeader.NEXT = 0;


    In SetPdf i set up the pdf
    In SendMail, i Attachment the file and send it.
    In ClearMyPdf, i clear pdf

    But the problem is sometimes some pdf hasn't been created, i think that the problem is that i don't put PdfCreator.cClose, but i can't to put it because doesn't run. Do you know something about it?
  • ara3nara3n Member Posts: 9,256
    Change. Report.run to
    Report.runmodal
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • gonzy1981gonzy1981 Member Posts: 156
    I did it, but nothing.

    I'm going to do a new form, with the errors, and in this form i'll try to generate the falure invoices to a pdf.
  • sabzamsabzam Member Posts: 1,149
    Hi Everybody,

    First of all well done ara3n for your coding. Just one question pls. How can I attach another pdf to the background? There should be a field for sure but I still can't find a list of fields available anywhere.

    Best Regards,

    Steve
  • sabzamsabzam Member Posts: 1,149
    Hi,

    I have managed to create the background but I would like to get the pdf from a picture in navision, do you think this is possible?

    Best Regards,

    sabzam
  • ara3nara3n Member Posts: 9,256
    well you could print the picture to PDF and then attach the PDF as background as you mentioned in your previous post.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • GegiiGegii Member Posts: 3
    Hi!

    I have a problem, and I need help. I want to save my pdf file directly to NAV 5.1 database table after create it. It is possible?
    I create a BLOP type in a table.

    Thx!
  • ara3nara3n Member Posts: 9,256
    yes it's possible.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • GegiiGegii Member Posts: 3
    Thx for the answer!
    But how? I've tried to search pdfcreator option like .AutosaveDirectory, but I find nothing.

    Gegii
  • ara3nara3n Member Posts: 9,256
    Look at my example.

    Once the pdf file is created, you need to save the file into blob file.

    MyBlob.save('C:\mypdffile.pdf\,false);
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • GegiiGegii Member Posts: 3
    Thx for the answer!
    It's works!
    Only one question: the pdf file exists in the file system. It is possible, that the file is not generated in the file system? i want to only my NAV database.

    regards, Gegii
  • ara3nara3n Member Posts: 9,256
    No it's not possible. You have to have the pdf file as intermediate. You can delete it after you load it into blob.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Dave_beDave_be Member Posts: 35
    Someone willing to share their codeunit for printing and emailing of the created PDF file?
  • rtamesrtames Member Posts: 56
    Hello,

    when I try to save a pdf I now get the PDFCreator options screen while I would like this to go silent. Is there something wrong in my code?


    onderaannemerslijstREC.SETFILTER("Job No.","Job No.");
    onderaannemerslijstREC.SETFILTER(Aktie, 'Calculator');
    datum := FORMAT(TODAY);
    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;
    Temppath := ENVIRON('TEMP');
    filename := "Job No." + ' ' + 'Calculator' + ' ' + datum +'.pdf';
    PDFCreatorOption.AutosaveDirectory := Temppath;
    PDFCreatorOption.AutosaveFormat := 0; PDFCreatorOption.AutosaveFilename := filename;
    PDFCreator.cOptions := PDFCreatorOption;
    PDFCreator.cClearCache();
    DefaultPrinter := PDFCreator.cDefaultPrinter;
    PDFCreator.cDefaultPrinter := 'PDFCreator';
    PDFCreator.cPrinterStop := FALSE;

    REPORT.RUN(78726,FALSE,FALSE,onderaannemerslijstREC);

    PDFCreator.cDefaultPrinter := DefaultPrinter;
    PDFCreator.cClose;
    CLEAR(PDFCreatorOption);
    CLEAR(PDFCreator);
    CLEAR(PDFCreatorError);
  • karstenrobertkarstenrobert Member Posts: 27
    Hi,

    the new PDFCreator 0.98 gives me some headaches too.

    I just noticed that the new PDFCreator ignores the Options set. PDFCreator didn't do anything and when I switched to the PDFCreator window it asked me some options and then created the PDF without error. The problem was that I set these options by code.

    You now need to use the PDFCreator.cSaveOptions(); so that the options you set are really used!!!

    PDFCreator.cOptions := PDFCreatorOption;
    PDFCreator.cSaveOptions();
    PDFCreator.cClearCache();
    

    Regards,
    Karsten
    Karsten Frank
    MCP - Dynamics NAV Developer
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Before installing PDFCreator, please read this http://www.mibuso.com/forum/viewtopic.php?f=16&t=35052
    David Singleton
  • ara3nara3n Member Posts: 9,256
    It's sad that the developer took this approach.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • LibertyMountainLibertyMountain Member Posts: 94
    Does PDFCreator allow you to add an overlay? I am experimenting with novaPDF, which is not free, but I had very quick positive results with their software. It also allows me to create pdf's programatically within NAV using a COM object. And based on the report I run, I can choose different overlays to add as a background to the document.
  • ara3nara3n Member Posts: 9,256
    I haven't looked at that feature, but bullzip allows you to set other pdfdocuments as background/overlay

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


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Dave_beDave_be Member Posts: 35
    how do you add the "defaultprinter" trick with bullzip?
  • ara3nara3n Member Posts: 9,256
    you can try and use report selection in NAV. set the report to print to specific printer.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Dave_beDave_be Member Posts: 35
    you can try and use report selection in NAV. set the report to print to specific printer.

    Ok, but what if you want to use the same report (like sales confirmation) to print and send as pdf?
    Then, you'll have to manually change the printer when you print the report...

    Create a duplicate of the report just to print as pdf?
  • ara3nara3n Member Posts: 9,256
    No, before running your code insert a record into report selection.
    Then afterwords delete the record.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
Sign In or Register to comment.