mibuso.com

Microsoft Business Solutions online community
It is currently Sat May 18, 2013 4:56 pm

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 293 posts ]  Go to page 1, 2, 3, 4, 5 ... 20  Next
Author Message
 Post subject: How to save Navision Reports as PDF
PostPosted: Mon May 14, 2007 2:04 am 
Offline
MVP Microsoft Dynamics NAV

Joined: Wed Dec 15, 2004 6:11 pm
Posts: 8699
Location: 3rd rock from sun
Country: United States (us)
Hello There are a lot of topics on creating pdf documents from Navision reports.
Here is an example on how to do it. There are a lot of windows pdf printers out there. The one I've used is a free open source version. To use this example please do the following.

Go to sourceforge.net and download PDFCreator

Here is a direct link.

http://sourceforge.net/project/showfiles.php?group_id=57796

Install the pdfCreator Printer. Once install copy and paste the form bellow, import it and compile it and run it. That's it.

Code: Select all
OBJECT Form 50100 Example Report to PDF files
{
  OBJECT-PROPERTIES
  {
    Date=05/13/07;
    Time=[ 8:06:37 PM];
    Modified=Yes;
    Version List=PDFCreator;
  }
  PROPERTIES
  {
    Width=14080;
    Height=7370;
    OnOpenForm=BEGIN
                 IF ISCLEAR(PDFCreator) THEN
                   CREATE(PDFCreator);
                 IF ISCLEAR(PDFCreatorError) THEN
                   CREATE(PDFCreatorError);

                 ReportID := REPORT::"Item List";
                 IF Object.GET(Object.Type::Report,'',ReportID) THEN;
                 FileDirectory := 'C:\';
                 FileName := 'example.pdf';


                 PDFCreatorError := PDFCreator.cError;

                 IF PDFCreator.cStart('/NoProcessingAtStartup',TRUE) = FALSE THEN
                      ERROR('Status: Error[' + FORMAT(PDFCreatorError.Number) + ']: ' + PDFCreatorError.Description);
               END;

  }
  CONTROLS
  {
    { 1000000000;CommandButton;4180;4070;5060;1210;
                                                 CaptionML=ENU=Print and save as PDF;
                                                 OnPush=BEGIN
                                                          Window.OPEN('processing');
                                                          WindowisOpen := TRUE;
                                                          IF FileName = '' THEN
                                                            ERROR('Please specify what the file should be saved as');

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

                                                          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;

                                                          REPORT.RUNMODAL(ReportID,FALSE,TRUE);
                                                        END;
                                                         }
    { 1000000001;TextBox;4180 ;990  ;3080 ;770  ;SourceExpr=ReportID;
                                                 TableRelation=Object.ID WHERE (Type=CONST(Report));
                                                 OnValidate=BEGIN
                                                              Object.GET(Object.Type::Report,'',ReportID);
                                                            END;
                                                             }
    { 1000000002;TextBox;4180 ;2310 ;9350 ;660  ;Editable=No;
                                                 SourceExpr=FileDirectory+FileName;
                                                 OnAssistEdit=VAR
                                                                txtWorkFileName@1000000001 : Text[250];
                                                                intSlashPos@1000000000 : Integer;
                                                                txtFileName@1000000002 : Text[100];
                                                              BEGIN
                                                              END;
                                                               }
    { 1000000003;Label  ;220  ;990  ;3190 ;770  ;CaptionML=ENU=Report ID }
    { 1000000004;Label  ;220  ;2310 ;3300 ;550  ;CaptionML=ENU=Save PDF as }
    { 1000000005;TextBox;7370 ;990  ;6050 ;770  ;Editable=No;
                                                 SourceExpr=Object.Name;
                                                 TableRelation=Object.ID WHERE (Type=CONST(Report));
                                                 OnValidate=BEGIN
                                                              Object.GET(Object.Type::Report,'',ReportID);
                                                            END;
                                                             }
  }
  CODE
  {
    VAR
      FileDirectory@1000000000 : Text[100];
      FileName@1000000010 : Text[100];
      ReportID@1000000001 : Integer;
      Object@1000000002 : Record 2000000001;
      PDFCreator@1000000006 : Automation "{1CE9DC08-9FBC-45C6-8A7C-4FE1E208A613} 4.1:{3A619AE4-50EC-46C8-B19E-BE8F50DD2F22}:'PDFCreator'.clsPDFCreator" WITHEVENTS;
      PDFCreatorOption@1000000005 : Automation "{1CE9DC08-9FBC-45C6-8A7C-4FE1E208A613} 4.1:{F8F15298-30FD-427C-BDFA-55E9AB615632}:'PDFCreator'.clsPDFCreatorOptions";
      PDFCreatorError@1000000004 : Automation "{1CE9DC08-9FBC-45C6-8A7C-4FE1E208A613} 4.1:{082391C9-8188-4364-B4FD-66A1524B2097}:'PDFCreator'.clsPDFCreatorError";
      DefaultPrinter@1000000003 : Text[200];
      Window@1000000007 : Dialog;
      WindowisOpen@1000000008 : Boolean;
      FileDialog@1000000009 : Codeunit 412;

    EVENT PDFCreator@1000000006::eReady@1();
    BEGIN

      PDFCreator.cPrinterStop := TRUE;
      PDFCreator.cDefaultPrinter := DefaultPrinter;
      PDFCreator.cClose();
      IF WindowisOpen THEN
        Window.CLOSE;
      WindowisOpen := FALSE;
    END;

    EVENT PDFCreator@1000000006::eError@2();
    BEGIN
      ERROR('Status: Error[' + FORMAT(PDFCreatorError.Number) + ']: ' + PDFCreatorError.Description);
    END;

    BEGIN
    {
      Author: Ahmed Amini
      Email: ara3n(NOSPAM)@hotmail.com
    }
    END.
  }
}



this is an example on how to create through code. You can use the example and modify it to automatically send statements to customers, email invoices all in one batch job.

Enjoy.

[EDIT] PLEASE BE AWARE THAT NEWER VERSION OF PDFCREATOR INSTALLS MALWARE :!:
I suggest to use Bullzip instead.You see the example here here. http://mibuso.com/blogs/ara3n/2008/08/0 ... ts-to-pdf/
Or Follow the following process to install PDF Creator without malware.
viewtopic.php?f=5&t=35076&start=0


[EDIT]

_________________
Rashed.

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


Last edited by ara3n on Tue Feb 23, 2010 1:46 pm, edited 7 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: Mon May 14, 2007 10:10 am 
Offline
MVP Microsoft Dynamics NAV

Joined: Tue Aug 14, 2001 7:01 am
Posts: 5315
Location: Prague
Country: Czech Republic (cz)
=D>

_________________
David Singleton
Dynamics NAV Freelancer
Dynamics Book
Go-Live International


Top
 Profile E-mail WWW  
 
 Post subject:
PostPosted: Mon May 14, 2007 12:56 pm 
Offline
MVP Microsoft Dynamics NAV
NAV TechDays 2013 attendee

Joined: Fri Dec 06, 2002 11:50 am
Posts: 3390
Location: Kontich, Belgium
Country: Belgium (be)
Too bad it won't install under Vista :|

_________________

Eric Wauters
MVP - Microsoft Dynamics NAV
My blog


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 14, 2007 1:37 pm 
Offline
MVP Microsoft Dynamics NAV

Joined: Wed Dec 15, 2004 6:11 pm
Posts: 8699
Location: 3rd rock from sun
Country: United States (us)
They are working for version 9.4 for Vista.

http://www.pdfforge.org/node/816

_________________
Rashed.

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


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 14, 2007 1:45 pm 
Offline
MVP Microsoft Dynamics NAV
NAV TechDays 2013 attendee

Joined: Fri Dec 06, 2002 11:50 am
Posts: 3390
Location: Kontich, Belgium
Country: Belgium (be)
OK, I'm an official PDFCreator tester now :|

_________________

Eric Wauters
MVP - Microsoft Dynamics NAV
My blog


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 14, 2007 2:35 pm 
Offline
MVP Microsoft Dynamics NAV

Joined: Wed Dec 15, 2004 6:11 pm
Posts: 8699
Location: 3rd rock from sun
Country: United States (us)
that is great. I'm guessing your company is using vista?
usually 99 % of Dynamics nav users don't use Vista. So it'll take a while to move to vista for nav users.

_________________
Rashed.

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


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 14, 2007 4:08 pm 
Offline
MVP Microsoft Dynamics NAV
NAV TechDays 2013 attendee

Joined: Fri Dec 06, 2002 11:50 am
Posts: 3390
Location: Kontich, Belgium
Country: Belgium (be)
My company isn't using Vista ... I'm using it.

And I'd like to keep it this way at the moment, knowing what stuff I had to do to make Vista "workable" for me.

_________________

Eric Wauters
MVP - Microsoft Dynamics NAV
My blog


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 14, 2007 5:19 pm 
Offline
MVP Microsoft Dynamics NAV

Joined: Wed Dec 15, 2004 6:11 pm
Posts: 8699
Location: 3rd rock from sun
Country: United States (us)
I'm trying to stay away from Vista as long as possible.
The longer I wait, the more apps will be ready for it.
My guess, probably when my laptop dies on me.

_________________
Rashed.

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


Top
 Profile  
 
 Post subject: Single report
PostPosted: Wed May 16, 2007 12:25 pm 
Offline

Joined: Wed Nov 22, 2006 4:28 pm
Posts: 444
Location: INDIA
Country: India (in)
Hey ma'an it's going grt but what i have to do when i want to print some particular no. of reports.
Example--i converted sales invoice in PDF ,what i have to do if i want to convert only few no. of invoices.
Where i have to mention it??


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 16, 2007 2:19 pm 
Offline
MVP Microsoft Dynamics NAV

Joined: Wed Dec 15, 2004 6:11 pm
Posts: 8699
Location: 3rd rock from sun
Country: United States (us)
you have to modify the object.
Or just go to the posted invoice and select print and then select pdfcreator as the printer.

_________________
Rashed.

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


Top
 Profile  
 
 Post subject: selected printing
PostPosted: Sat May 19, 2007 7:31 am 
Offline

Joined: Wed Nov 22, 2006 4:28 pm
Posts: 444
Location: INDIA
Country: India (in)
What if i want to print sales invoice report and that too invoice no. 10,20,30.... etc. only.
where can i give the values in coding.
Thanx in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 28, 2007 3:54 pm 
Offline

Joined: Tue Jun 22, 2004 3:17 pm
Posts: 104
Location: UK
Country: United Kingdom (uk)
Thank you very much for this Rashed.

We only have report writer but have been able to follow this and create then send emails for purchase orders, sales confirmations and invoices.

I did have problems in saving the file before emailing, but this was overcome by setting the printer properties (advanced) to print directly to printer instead of the default Spool.

Not sure if there is an automation for this.

Anyway over the moon \:D/


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 09, 2007 6:10 am 
Offline
MVP Microsoft Dynamics NAV

Joined: Wed Dec 15, 2004 6:11 pm
Posts: 8699
Location: 3rd rock from sun
Country: United States (us)
you are welcome.

_________________
Rashed.

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


Top
 Profile  
 
 Post subject: Thanks!
PostPosted: Fri Jul 13, 2007 11:13 am 
Offline

Joined: Fri Jul 13, 2007 11:10 am
Posts: 4
Location: Hong Kong
Country: Hong Kong (hk)
Very good.. thanks for your help!!! =D>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 13, 2007 1:34 pm 
Offline
MVP Microsoft Dynamics NAV

Joined: Wed Dec 15, 2004 6:11 pm
Posts: 8699
Location: 3rd rock from sun
Country: United States (us)
welcome.

_________________
Rashed.

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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 293 posts ]  Go to page 1, 2, 3, 4, 5 ... 20  Next

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum


Search for:
Jump to: