How to save Navision Reports as PDF

1356710

Comments

  • NizarzNizarz Posts: 12Member
    thanks rashed for that clarifications, but my problem is how to send a pdf report from Navision by mail ; i want to mail the report directly from navision !! ](*,)
  • ara3nara3n Posts: 9,141Member
    That's a totally different issue.
    Search Mibuso for smtp
  • holssonholsson Posts: 1Member
    Oh an d the reason I was actually here....


    Has anyone else come across the error where PDF objects created in ver. 0.9.3 won't run on 0.9.5 and vica versa. Basically the comand below will only run on a coumputer running the same version of PDFCreator that it ws complied with.

    The issue is the command
    PDFCreatorOption :=  PDFCreator.cOptions;
    

    Which gives the message:
    This message is fo C/AL programmers:
    Invalid assignment. It is not possible to assign a _clsPDFCreatorOptions to a clsPDFCreatorOptions.

    Its clearly an issue with wich dll you have registered, and I am pretty sure its a PDF creator issue, not a NAV issue.

    Its damn anoying having to use a different computer to compile objects to get this to work, and worst is when a client has computers with differnt version of PDF creator installed.

    Has anyone solved this?


    Use the older build of PDFCreator "PDFCreator-0_9_3_GPLGhostscript.exe"
  • MukkerMukker Posts: 10Member
    Hi

    When I try to run my form (the one showed here and copyed/imported to Navision) I get the error "This message is for C/AL programmers.......
    Could not invoke the member cClose, the OLE control or the Automation server returned an unknown error code.
    I have tried to uninstall the PDFCreator and then reinstall it. But Navision starts hanging until the service "PDFCreator" is killed.

    I'm using the "old" 0_9_3 version.

    Any ideas would be nice - thanks.
  • David_SingletonDavid_Singleton Posts: 5,367Member
    holsson wrote:
    ...Has anyone else come across the error where PDF objects created in ver. 0.9.3 won't run on 0.9.5 and vica versa. Basically the comand below will only run on a coumputer running the same version of PDFCreator that it ws complied with.
    ...



    Use the older build of PDFCreator "PDFCreator-0_9_3_GPLGhostscript.exe"

    No I think you missed the error.

    Basically if I compile the object in 0.9.3 then the objects will not run on 0.9.5 and if I compile them on 0.9.5 they wont run on 0.9.3

    This is not a specific bug in either version, simply that they are incompatible.
    David Singleton
  • NaveenReddyNaveenReddy Posts: 53Member
    Hi Guys,

    I am trying to print the Sales invoice but i cannot name the file as invoice number or even i cannot save it as C:\example.pdf. Its always taking what ever is set on the printer options in PDFcreator autosave settings. I am using vista.
    Do i need o change anything?
  • ara3nara3n Posts: 9,141Member
    uncheck outsave in the options in PDFcreator.
  • NaveenReddyNaveenReddy Posts: 53Member
    If I uncheck autosave then it always pops up the save screen to select the location and file name. But i want this to run as a bacth process to print individual invoices with filename as invoice number with manual interaction.

    Wierd this is i used your sample code to run the itemlist with c:\example.pdf. But it never takes that location or filename.
  • David_SingletonDavid_Singleton Posts: 5,367Member
    If I uncheck autosave then it always pops up the save screen to select the location and file name. But i want this to run as a bacth process to print individual invoices with filename as invoice number with manual interaction.

    Wierd this is i used your sample code to run the itemlist with c:\example.pdf. But it never takes that location or filename.

    I had some similar issues as this, but it was because I had been playing with the PDF creator settings ](*,) . Eventually I just uninstalled and reinstalled with the default settings and it all worked.
    David Singleton
  • garakgarak Posts: 3,301Member
    mhm, i'm not use PDF Creator.
    I've a Linuxserver with samba and with a little config on smb.conf the samba server also work as PDF PrintServer which can also used from Windows systems. And he sends the pdf back to the user per mail, because he read the userdata from AD (Active directory). This works excellent

    Regards
    Do you make it right, it works too!
  • NaveenReddyNaveenReddy Posts: 53Member
    HI,

    I did reinstalled the pdfcreator but no luck. still asking me to pick the location and name. its not taking c:\example.pdf filename
  • ricnunesricnunes Posts: 3Member
    HI,

    I did reinstalled the pdfcreator but no luck. still asking me to pick the location and name. its not taking c:\example.pdf filename

    I've exactly the same problem. It doesn't assume the filename and directory that i choose in navision.

    BR
  • ondina.caldeiraondina.caldeira Posts: 1Member
    Hello.
    I need some help. :(

    I have this code in a codeunit:

    OnRun()
    Teste('171920');

    Teste(NrDocumento : Code[20])
    gtxtFileDirectory := 'D:\Path1\';
    gtxtFileNamePDF2 := 'xx- ' + NrDocumento + '.pdf';
    IF EXISTS(gtxtFileDirectory+gtxtFileNamePDF2+'.old') THEN
    ERASE(gtxtFileDirectory+gtxtFileNamePDF2+'.old');

    IF EXISTS(gtxtFileDirectory+gtxtFileNamePDF2) THEN
    IF RENAME(gtxtFileDirectory+gtxtFileNamePDF2,gtxtFileDirectory+gtxtFileNamePDF2+'.old') THEN;

    TesteImprimirPDFCreator(gtxtFileDirectory,
    gtxtFileNamePDF2,
    T112,NrDocumento);

    TesteImprimirPDFCreator(gtxtFileDirectory : Text[250];gtxtFileNamePDF2 : Text[250];T112 : Record "Sales In

    IF ISCLEAR(gautPDFCreator) THEN
    CREATE(gautPDFCreator);

    IF ISCLEAR(gautPDFCreatorError) THEN
    CREATE(gautPDFCreatorError);

    gautPDFCreatorError := gautPDFCreator.cError;

    IF gautPDFCreator.cStart('/NoProcessingAtStartup') = FALSE THEN
    MESSAGE('Status: Error: ' + gautPDFCreatorError.Description);

    gautPDFCreatorOption2 := gautPDFCreator.cOptions;
    gautPDFCreatorOption2.UseAutosave := 1;
    gautPDFCreatorOption2.UseAutosaveDirectory := 1;
    gautPDFCreatorOption2.AutosaveDirectory := gtxtFileDirectory;
    gautPDFCreatorOption2.AutosaveFormat := 0;
    gautPDFCreatorOption2.AutosaveFilename := gtxtFileNamePDF2;

    gautPDFCreator.cOptions := gautPDFCreatorOption2;
    gautPDFCreator.cClearCache();
    DefaultPrinter := gautPDFCreator.cDefaultPrinter;
    gautPDFCreator.cDefaultPrinter := 'PDFCreator';
    gautPDFCreator.cPrinterStop := FALSE;

    T112.SETRANGE(T112."No.",NrDocumento);
    REPORT.RUNMODAL(206, FALSE, TRUE,T112);
    // REPORT.RUNMODAL(66012, FALSE, TRUE,T112);

    WHILE NOT EXISTS(gtxtFileDirectory + gtxtFileNamePDF2) DO;

    gautPDFCreator.cPrinterStop := TRUE;
    gautPDFCreator.cDefaultPrinter := DefaultPrinter;
    gautPDFCreator.cCloseRunningSession;
    gautPDFCreator.cClose;

    CLEAR(gautPDFCreator);
    CLEAR(gautPDFCreatorError);
    CLEAR(gautPDFCreatorOption2);

    I run de codeunit and everything is ok.

    But I need to put that in a Form. In Codeunit 82 (Sales-Post + Print)

    What I realy want to is:
    --> Posting and Print --> create a excel file (this work ok, I create a process only report that create the excel and is call instead of the normal report)
    --> Posting and Print PDF --> create a excel file and a pdf file. This create a excel file, a pdf file, but then PDFCreator process don’t close. In this case in then windows task manager the processe of the PDFCreator is running and I have to kill that.

    I change de code of the function PrintReport and use the code equal to the code in the test.
    Why this do not work?


    Thanks.
    Thanks.
  • ptech5443ptech5443 Posts: 28Member
    Does anyone know if this works with Nav 2.60 US? I am trying to use this functionality and have run into an issue with the following line of code:

    PDFCreator.cOptions := PDFCreatorOption;

    I get the following error

    A maximum of 0 parameters must be used when calling the function.

    Does anyone know what I am doing wrong?
  • David_SingletonDavid_Singleton Posts: 5,367Member
    ptech5443 wrote:
    Does anyone know if this works with Nav 2.60 US? I am trying to use this functionality and have run into an issue with the following line of code:

    PDFCreator.cOptions := PDFCreatorOption;

    I get the following error

    A maximum of 0 parameters must be used when calling the function.

    Does anyone know what I am doing wrong?

    Its the same as this.
    Oh an d the reason I was actually here....


    Has anyone else come across the error where PDF objects created in ver. 0.9.3 won't run on 0.9.5 and vica versa. Basically the comand below will only run on a coumputer running the same version of PDFCreator that it ws complied with.

    The issue is the command
    PDFCreatorOption :=  PDFCreator.cOptions;
    

    Which gives the message:
    This message is fo C/AL programmers:
    Invalid assignment. It is not possible to assign a _clsPDFCreatorOptions to a clsPDFCreatorOptions.

    Its clearly an issue with wich dll you have registered, and I am pretty sure its a PDF creator issue, not a NAV issue.

    Its damn anoying having to use a different computer to compile objects to get this to work, and worst is when a client has computers with differnt version of PDF creator installed.

    Has anyone solved this?
    David Singleton
  • ptech5443ptech5443 Posts: 28Member
    David,
    Thanks for the reply.

    I found that the same code did indeeed compile and then work as deisgned after I opened the same database using Nav 4.0 SP3. So I am going to assume that the exe version was the issue and not the version of PDF creator.

    ara3n,
    Thanks for the example. =D>
  • ara3nara3n Posts: 9,141Member
    ptech5443 wrote:
    David,
    Thanks for the reply.

    I found that the same code did indeeed compile and then work as deisgned after I opened the same database using Nav 4.0 SP3. So I am going to assume that the exe version was the issue and not the version of PDF creator.

    ara3n,
    Thanks for the example. =D>

    You are welcome and happy coding.
  • tejateja Posts: 102Member
    Hello ara3n,
    When I compiled it, it showed me a error as [You connot enter 'Item List' in ReportNo.Then the cursor jump to OnOpenForm() trigger where have a statement is
    ReportID := REPORT::"Item List";

    Did I have do anything wrong? :?: or do you have a report call "Item List"? then I need to change to any of mine?
    thank you.


    Did I made anything wrong, can u tell me where I went wrong

    Thank you
  • tejateja Posts: 102Member
    I am sorry , I found the error..
  • tejateja Posts: 102Member
    hi ara3n,

    It is very good. Thanks for u r help.
  • Jay2007Jay2007 Posts: 50Member
    Hi there,


    I have implemented this PDF Creator solution and it is working very well for me apart from one problme.

    Randomly, the PDFCreator program will not close when the PDFCreator.cClose(); function is called.


    Has anyone experienced this issue???

    Thanks,

    Jay
  • mgmmgm Posts: 126Member
    Jay,

    Same problem here. But not randomly :? .
    And in NAV the Dialog Processing is open.
    The PDFCreator keeps running in the Task Manager.
    After ending it, NAV returns an error: could not invoke...

    Maarten
  • ara3nara3n Posts: 9,141Member
    I'm thinking of creating another example using another pdf printer. I will keep you guys posted.
  • mgmmgm Posts: 126Member
    I remember using pdf995 long time ago.
    Does anyone have experience with this one recently?
  • ara3nara3n Posts: 9,141Member
    Ok here is another solution using BullZip PDF Printer.

    http://mibuso.com/blogs/ara3n/


    direct link
    http://mibuso.com/blogs/ara3n/2008/08/0 ... ts-to-pdf/


    OBJECT Form 50101 Example Report to PDF files
    {
      OBJECT-PROPERTIES
      {
        Date=07/31/08;
        Time=10:44:15 PM;
        Modified=Yes;
        Version List=PDFCreator;
      }
      PROPERTIES
      {
        Width=9460;
        Height=3960;
      }
      CONTROLS
      {
        { 1000000000;CommandButton;990;660;5060;1210;CaptionML=ENU=Print and save as PDF;
                                                     OnPush=BEGIN
                                                              PrintToBullZip;
                                                            END;
                                                             }
      }
      CODE
      {
        VAR
          FileDirectory@1000000000 : Text[100];
          FileName@1000000010 : Text[100];
          ReportID@1000000001 : Integer;
          Object@1000000002 : Record 2000000001;
          BullZipPDF@1000000004 : Automation "{61CB5BFA-AFE6-4B0F-A4BB-7F3D4999EE52} 3.2:{BEBDC1DF-D793-4F6C-B8FF-E831A1C2595C}:'Bullzip'.PDFPrinterSettings";
          Window@1000000007 : Dialog;
          RunOnceFile@1000000005 : Text[1000];
          TimeOut@1000000006 : Integer;
          Customer@1000000003 : Record 18;
          Customer2@1000000011 : Record 18;
    
        PROCEDURE PrintToBullZip@1000000000();
        BEGIN
          IF ISCLEAR(BullZipPDF) THEN
            CREATE(BullZipPDF);
    
          ReportID := REPORT::"Customer - List";
          FileDirectory := 'C:\';
    
          Window.OPEN('processing  Cusomer ######################1##');
    
          Object.GET(Object.Type::Report,'',ReportID);
    
          IF Customer.FINDSET THEN REPEAT
            Window.UPDATE(1,Customer."No.");
            FileName := Customer."No." + '.pdf';
            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);
            Customer2 := Customer;
            Customer2.SETRECFILTER;
            REPORT.RUNMODAL(ReportID,FALSE,FALSE,Customer2);
    
            TimeOut := 0;
            WHILE EXISTS(RunOnceFile) AND (TimeOut < 10) DO BEGIN
                SLEEP(1000);
                TimeOut := TimeOut + 1;
            END;
    
          UNTIL Customer.NEXT = 0;
    
          Window.CLOSE;
        END;
    
        BEGIN
        {
          Author: Ahmed Amini
          Email: ara3n(NOSPAM)@hotmail.com
        }
        END.
      }
    }
    
    


    You can download BullZip Freeware from

    http://www.bullzip.com/download.php
  • ara3nara3n Posts: 9,141Member
    Btw bullzip doesn't have a way to change the the pdf printer to default printer, so you have to set it up in printer selection in NAV. Or make the pdf Printer as default.

    Bullzip works on vista and 64 bit compatible.
  • mgmmgm Posts: 126Member
    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
  • ara3nara3n Posts: 9,141Member
    That's a good solution with printerSelection that the user could add to the code.
    I would add USERID in there as well. So just in case other people are printing the same report and it doesn't automatically select that printer.
    Or maybe delete the record at the end of the process
  • SpyrootSpyroot Posts: 45Member
    Hello guys,

    I'm all confused, should I create a report, a form or a code unit to place the code that is on the top.

    Also should I delete "{}"? since NAV ignore the code that is between {}. What should I do.

    Help please, I'm trying to implement automatic report with job scheduler and send them via email.
    do you think that using this code may help? I'm using NAV 3.70

    Thank you for all your support.
  • ara3nara3n Posts: 9,141Member
    Copy everything in the code section from

    OBJECT Form 50101 Example Report to PDF files
    {
    ....

    to last braket.
    }


    Open Notepad and paste it.

    Then save the notepad txt file as something. In Navision open object designer and import the txt file you saved, and then compile it.

    If you have already a Form 50101 object, then change number in the text file.
    You need dev license to import txt files.

    Alternatively you can create a new empty report, and create a new function called
    PrintToBullZip

    and copy evering from
    IF ISCLEAR(BullZipPDF) THEN
    CREATE(BullZipPDF);
    ...

    until

    Window.CLOSE;

    Create Global Variables
    FileDirectory@1000000000 : Text[100];
    FileName@1000000010 : Text[100];
    ReportID@1000000001 : Integer;
    Object@1000000002 : Record 2000000001;
    BullZipPDF@1000000004 : Automation "{61CB5BFA-AFE6-4B0F-A4BB-7F3D4999EE52} 3.2:{BEBDC1DF-D793-4F6C-B8FF-E831A1C2595C}:'Bullzip'.PDFPrinterSettings";
    Window@1000000007 : Dialog;
    RunOnceFile@1000000005 : Text[1000];
    TimeOut@1000000006 : Integer;
    Customer@1000000003 : Record 18;
    Customer2@1000000011 : Record 18;

    and onPrereport call this new function PrintToBullZip.

    Make sure Bull Zip printer is your default printer
Sign In or Register to comment.