Problem with PDFCreator

miksy123
Member Posts: 10
I am trying to automatically save a sales order to a specified location on my hard drive and I want to do it from inside the report (I have a reason for doing this). The problem is I get one big NOTHING. The file isn't there! Here is the code that I have in OnPostTrigger:
I have ordered the report to sleep for 15 seconds (15000 miliseconds) and wait for the .PDF file to be created, but I still get nothing. It simply doesn't create the file. I have only one Invoice and I think 15 seconds is more than enough for PDFCreator to create a file. I succeeded saving the file but I had to first initialize the PDFCreator printer from a codeunit, then RUNMODAL the report (also from codeunit) without starting the ReqWindow like this:
I don't want to do it like this! I have a reason for not doing something like this and I want the code inside the report! I want it to create a .PDF file every time I preview/print the report...even from Object Designer. The user also needs to filter the report, use the request form before printing etc.
Thanks for helping me!
CLEAR(PDFCreatorOption); CLEAR(PDFCreator); CLEAR(PDFCreatorError); FileDirectory := 'C:\'; FileName := 'example1.pdf'; 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[' + FORMAT(PDFCreatorError.Number) + ']: ' + PDFCreatorError.Description); IF ISCLEAR(PDFCreatorOption) THEN CREATE(PDFCreatorOption); PDFCreatorOption := PDFCreator.cOptions; PDFCreatorOption.UseAutosave := 1; PDFCreatorOption.UseAutosaveDirectory := 1; PDFCreatorOption.AutosaveDirectory := FileDirectory; PDFCreatorOption.AutosaveFormat := 0; PDFCreatorOption.AutosaveFilename := FileName; PDFCreator.cOptions := PDFCreatorOption; PDFCreator.cSaveOptions(PDFCreatorOption); PDFCreator.cClearCache(); DefaultPrinter := PDFCreator.cDefaultPrinter; PDFCreator.cDefaultPrinter := 'PDFCreator'; PDFCreator.cPrinterStop := FALSE; SLEEP(15000); PDFCreator.cPrinterStop := TRUE; PDFCreator.cDefaultPrinter := DefaultPrinter; PDFCreator.cClose; CLEAR(PDFCreator);
I have ordered the report to sleep for 15 seconds (15000 miliseconds) and wait for the .PDF file to be created, but I still get nothing. It simply doesn't create the file. I have only one Invoice and I think 15 seconds is more than enough for PDFCreator to create a file. I succeeded saving the file but I had to first initialize the PDFCreator printer from a codeunit, then RUNMODAL the report (also from codeunit) without starting the ReqWindow like this:
REPORT.RUNMODAL(ReportSelection."Report ID",FALSE,TRUE,SalesHeader);
I don't want to do it like this! I have a reason for not doing something like this and I want the code inside the report! I want it to create a .PDF file every time I preview/print the report...even from Object Designer. The user also needs to filter the report, use the request form before printing etc.
Thanks for helping me!
0
Comments
-
[Topic moved from 'NAV Tips & Tricks' forum to 'NAV/Navision Classic Client' forum]Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
You have this code in OnPostTrigger of what? The reports itself? How you are handling on which printer the report is printed? You need to print it on PDFCreator printer and this code you are using must be used before and after the report is printed, it means before REPORT.RUN is called (setting the parmeters) and after it ended (waiting for creation of the file).0
-
OMG I just realized that this doesn't work if I run the report with ReqWindow...0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K 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
- 320 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