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. } }
Comments
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
http://www.pdfforge.org/node/816
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
usually 99 % of Dynamics nav users don't use Vista. So it'll take a while to move to vista for nav users.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
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
The longer I wait, the more apps will be ready for it.
My guess, probably when my laptop dies on me.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
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??
Or just go to the posted invoice and select print and then select pdfcreator as the printer.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
where can i give the values in coding.
Thanx in advance.
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/
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
http://www.cutepdf.com/Products/CutePDF/writer.asp
Download and install both CutePDF and Converter.
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
And free usually means "not supported" in the way when something goes wrong, you're on your own...
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
RIS Plus, LLC
You mean CutePDF ?
I should have to try this ... .
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
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.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
RIS Plus, LLC
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.
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.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
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.
Can any 1 tell me what it is?
Installed PDF writer already.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
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.