How to save Navision Reports as PDF
ara3n
Member Posts: 9,258
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.
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]
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.
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]
0
Comments
-
=D>David Singleton0
-
0
-
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.0 -
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.0 -
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??0 -
you have to modify the object.
Or just go to the posted invoice and select print and then select pdfcreator as the printer.0 -
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.0 -
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/0 -
you are welcome.0
-
Very good.. thanks for your help!!! =D>0
-
welcome.0
-
I am using free software CutePDF. Just run report, print and select CutePDF Writer as a printer. That will generate you pdf-file. I am using XP SP2.
http://www.cutepdf.com/Products/CutePDF/writer.asp
Download and install both CutePDF and Converter.0 -
nothing quiet beats Free.0
-
-
Hi
I have imported the Code U have given in Mibuso Forum.
The 'Report to PDF Conversion' its working fine But as U suggest in that when the Report is Run it should Print and Make PDF of that.
The First of it is working that is making PDF of the Report But it shoud't Print the Report along with it.
Regards
Kiran.Hi0 -
Check your PDF Creator Setting. In the Print Program option make sure the setting Print after saving is unchecked.0
-
Yes I mean CutePDFWaldo wrote:
0 -
Hi
Rashed. Its very much useful to convert the Report in to some readable form by PDF.
I have imported your code its working fine for Converting the specified PDF from Backend but not able to Print that.
Is there anyway to get lookup from the Req.form the report list So that we can select the Particular Report to Convert in to PDF and at the same
time print also.
Pls, Check that and Provide me the Solution.
Regards,
Kiran.Hi0 -
Hello KiranKumar
You don't need the example in order to create a report and print it at the same time.
you just print any nav report and select the pdfcreator as your printer.
As far as modifyin the code that part you can try and do it yourself. This example I've posted here is an example on how to do it. You can modify it how ever you want to.
There are thousands of way that people would modify it to make it work for what they need. I will not post every request or do your programming. You can try and find and NSC to do it for you. If you have specific questions concerning code, pleasae feel free and ask them away.0 -
I have no mean of Critisise the Code you written.
I am very much enthusiastic to know more than what i learnt till now..
you know its just meet of discussion.
Once again.............Sorrry
Regards
kiran.Hi0 -
I seem to be missing CU 412, therefor I can't compile the form.
Can any 1 tell me what it is?
Installed PDF writer already.0 -
delete the variable and any place where it's being reference. you don't need it.0
-
Thanks, I will try that0
-
The code is working fine, but i'm facing some problem
1. i dont want the report to be printed. So i commented the code for that, then it is not working
2. Even if i changed the name of the output file, output pdf file is always saved as 'example'.
Thanks & Regards,
Shabna.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 328 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions


