How to save Navision Reports as PDF
Comments
-
Thanks for the reply.
But is it possible to use the GhostScript .dll to handle the pdf printing? Or do I always have to rely on printers like PDFCreator that have some versions that are not stable?
Im running PDFCreator on Windows server 2008 and it has not been working.0 -
0
-
Back from Antwerp and all hangovers recovered from. Annoying PDF Bullzip problem here and I can not seem to find it on Search. Perhaps the brain cells required to do so were killed on Thursday night.
I have a reporting codeunit running which a couple of Nav Clients are running at the same times on the same server. When a report is running it uses the code:PrinterSelection.RESET; IF NOT PrinterSelection.GET(USERID, SetupValuesCAL."Object No.") THEN BEGIN deletePrinterSelection := TRUE; CLEAR(PrinterSelection); PrinterSelection."User ID" := USERID; PrinterSelection."Report ID" := SetupValuesCAL."Object No."; PrinterSelection."Printer Name" := 'Bullzip PDF Printer'; PrinterSelection.INSERT; END ELSE BEGIN resetPrinterSelection := TRUE; PrinterSelectionBackup := PrinterSelection; PrinterSelection."Printer Name" := 'Bullzip PDF Printer'; PrinterSelection.MODIFY; END;
The Object No. of the report I want to auto run coming from a Setup Table.
I then init the Bullzip settings I require:IF ISCLEAR(BullZipPDF) THEN CREATE(BullZipPDF); BullZipPDF.Init; BullZipPDF.LoadSettings; RunOnceFile := BullZipPDF.GetSettingsFileName(TRUE); BullZipPDF.SetValue('Output', FilePathName); 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);
Then I RUNMODAL the report and out it usually prints, quite often to c:\temp where it is attached to an email and sent to the relevant users. The Filename usually includes COMPANYNAME and USERID and a TimeStampe so there is 0% chance in my company of two files being created with the same file name.
I then do a little sleepy time as suggested somewhere else on the forum when I first set this up (Cant remember where now, probably this thread):WHILE EXISTS(RunOnceFile) AND (TimeOut < 10) DO BEGIN SLEEP(1000); TimeOut := TimeOut + 1; END;
All of this works fine 95% of the time but I have seen two behaviours I can not explain and can rarely reproduce, if at all.
1) On very rare occasions the Filename assigned to a PDF is from one client but the actual PDF itself is from another. Can never reproduce this on purpose however
2) On other occasions, reproducible but only sporadically, the Bullzip window which asks you where you want to save the PDF opens. Normally the code above sets this not to appear and sets the file path and name etc. This of course means the PDF is not created until a user manually intervenes and so the auto matic PDF creation and Email sending has failed.
Are these known issues I can not find in the search? Has anyone found solutions for them?0 -
My first guess (without using bullzip) is add a sleep(1000) after "BullZipPDF.WriteSettings(TRUE); "
So give it time write.0 -
I think the issue is stemming from the fact many user accounts are all running Bullzip at the same time(s).
Problem is I can not imagine how.
The Runonce file is created in the local users account. Documents/username/etc.etc.etc.
So 10 users logged into one server all printing with bullzip RunOnceFiles should not really be clashing with each other?
I have put SLEEPS and TIMEOUTS at every place I can think of. Short ones, long ones, many ones, few ones. No combination appears to be working.
I even tried to remove the "AND (TimeOut < 10)" entirely but when the problems happen the client just hangs forever then.
I am wondering if at this stage it is worth abandoning Bullzip entirely and redeveloping with a new solution. Anyone implemented anything else before?0 -
i answered my own question...i used this command to install PDFCreator.
PDFCreator-1_0_0_setup.exe /SILENT /components=\"!toolbar\" /tasks=\"!desktop_icon\" /f /norestart
Thanks to page2pagepro0 -
G8tor wrote:Thanks for the reply.
But is it possible to use the GhostScript .dll to handle the pdf printing? Or do I always have to rely on printers like PDFCreator that have some versions that are not stable?
Im running PDFCreator on Windows server 2008 and it has not been working.
I use Ghostscript but not the automation objects. Briefly -
1. Download Ghostscript and install
2. Install some vanilla printer driver (I use an HP laserjet 4200/4300 PCL6)
3. Download and install Redmon redirection program which will create port RPT1
4. Change the printer port to RPT1 and direct to Ghostscript using the arguments -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile="C:\your path name\%d.pdf" -dBATCH -f -
5. Add the printer to NAV and select it in the code that runs the report.
6. The argument %d.pdf will create the report output with the report caption from NAV so after running the report you probably want to add code to rename the file to the customer number or whatever.
I do actually have a problem which is why I was looking through Mibuso and found this thread. I have one instance where I want to copy the pdf to a different folder with a different name. But for some reason, although the initial pdf is created OK, the COPY gives an error in NAV and creates an empty file in the target folder - anyone got any idea why this might be so?0 -
If you are performing any action on the file after the report has completed, you need to add a sleep command to give the operating system enough time to recognize the file has been created in that directory.
An OS guru could go into more detail of what is going on behind the scenes. I have found a delay of a few seconds guarantees success.David Machanick
http://mibuso.com/blogs/davidmachanick/0 -
davmac1 wrote:If you are performing any action on the file after the report has completed, you need to add a sleep command to give the operating system enough time to recognize the file has been created in that directory.
An OS guru could go into more detail of what is going on behind the scenes. I have found a delay of a few seconds guarantees success.
Tried that - even with a delay of 30 seconds I get the same result.0 -
Can you post the specific error message?
Things I would look at, depending on the error message:
1) The code sets the paramters, executes the NAV report, then does the copy
2) filename including extension is correct in the code
3) directory pathname is valid and no syntax problems
4) the process performing the operations has the permissions to write to the directory.David Machanick
http://mibuso.com/blogs/davidmachanick/0 -
I usually add code to change the timestamp on the file. the NAV function returns a true if sucessful. If the file is still locked it will return a false.
Add a repeat clause.
While not SETSTAMP(Name,date,time) do
end;0 -
davmac1 wrote:Can you post the specific error message?
Things I would look at, depending on the error message:
1) The code sets the paramters, executes the NAV report, then does the copy
2) filename including extension is correct in the code
3) directory pathname is valid and no syntax problems
4) the process performing the operations has the permissions to write to the directory.
I was a bit hasty in dismissing the sleep option: I have all the FILE operations in loops and the max number of iterations and the SLEEP time in each iteration are read from a setup record. When I increase both these values massively the COPY works OK but the whole operation is taking nearly 2 minutes.
The error message I get if I do not trap it is
You cannot use the file C:\PDFInvoices\Temp\User Folder\Customer Sales Invoice.pdf because it is already in use.
I shall try Rashed (ara3n) suggestion of using the timestamp to test if the file has been unlocked because currently I am only testing to see if it exists before trying to copy0 -
That is a problem with the sleep operation if you have a large number of pdfs. I have found it works okay for my users.
Please let us know how Rashed's method works out for you - it sounds like a much faster option, and better than trial and error with the sleep method.David Machanick
http://mibuso.com/blogs/davidmachanick/0 -
personally , I use Nitro PDF..
and when I want print the report, I choose the virtual printer NITRO
That 's the Link :
http://en.softonic.com/s/free-nitro-pdf-printer0 -
Have finally got round to trying Rashed's SETSTAMP suggestion and it works great. I previously was using file.COPY in a loop after testing that the pdf had been created and I wonder if that were somehow locking the file, because putting SETSTAMP in a loop with just the same sleep parameters (I use two, user configurable, one for the number of loops, and another for the delay time in each loop) I get no errors.
Thanks for your help Rashed.
I used to use PDF Creator and occasionally had the same problem as Mauddib with a payroll application - the file would have one employee's number as the filename but another employees payslip in it. At least the create - rename route puts a lot more of the control in NAV rather than relying on the pdf printer.0 -
Can it be used in Dynamics Nav 2013 ?
i tried add variable in 2013, failed0 -
-
Does your report has RDLC data?
Are you using client-server environment or single machine?
if clinet-server then the file will be created on system where servicetier is installed..0 -
mohana_cse06 wrote:Does your report has RDLC data?
Are you using client-server environment or single machine?
if clinet-server then the file will be created on system where servicetier is installed..
my pc is as client
the service is in the server
do i need to generate from server?0 -
File must have generated in server pc's D folder, please check..0
-
As far as I am aware SAVEASPDF will only work with RTC and does nothing in the Classic client.0
-
hi there,
when we print the report to pdf from Navision, is there anyway we can set the property(non-editing)/security setting of the pdf file to prevent user to edit the pdf file?
Thank you.
regards,
Rachel0 -
=D>Abid Hussain / Mobile : 0561206303 / Dubai/ UAE0
-
hi, I have successfully implemented the above, thanks for the solution.
I have implemented on NAV2009 using pdfcreator.
The client would like to have the pdfcreator installed only on the server and the files would be saved directly on the server too. is this possible without the NAS? I tried to select the printer as the 'Printer Selection' but it seems that only locally saved printers can be added..
Any help would be appreciated.
Thanks!!0 -
if you are running classic client, the pdf printer needs to be installed on client0
-
yes they're using the Classic Client .. so it has to be installed on each and every client, thanks a lot!!0
-
sorry guys, i've a problem. I'm trying to print a classic report from NAV 2009 R2 to PDF. I readed previous posts, but i don't understand where is my mistake:
CompInfo.GET; GeneralLedgerSetup.GET; GeneralLedgerSetup.TESTFIELD("Accounting Books Path"); IF ISCLEAR(PDFCreator) THEN CREATE(PDFCreator,TRUE,TRUE); IF ISCLEAR(PDFCreatorError) THEN CREATE(PDFCreatorError,TRUE,TRUE); PDFCreatorError := PDFCreator.cError; IF PDFCreator.cStart('/NoProcessingAtStartup',TRUE) = FALSE THEN ERROR('Status: Error[' + FORMAT(PDFCreatorError.Number) + ']: ' + PDFCreatorError.Description); PDFCreatorOption := PDFCreator.cOptions; PDFCreatorOption.AutosaveDirectory := gVATReportSetup."VAT Path Destination"; PDFCreatorOption.AutosaveFilename := gFileName; PDFCreatorOption.UseAutosave := 1; PDFCreatorOption.UseAutosaveDirectory := 1; PDFCreatorOption.AutosaveFormat := 0; PDFCreator.cOptions := PDFCreatorOption; PDFCreator.cSaveOptions(); PDFCreator.cClearCache(); DefaultPrinter := PDFCreator.cDefaultPrinter; PDFCreator.cDefaultPrinter := 'PDFCreator'; PDFCreator.cPrinterStop := FALSE; IF pComp THEN BEGIN REPORT.RUNMODAL(50134, FALSE, TRUE); END ELSE BEGIN REPORT.RUNMODAL(50196, FALSE, TRUE); END; PDFCreator.cDefaultPrinter := DefaultPrinter; PDFCreator.cClose; CLEAR(PDFCreatorOption); CLEAR(PDFCreator); CLEAR(PDFCreatorError);
i call this function many time (15/30 times) by loop (i loop on standard 12147 italian table).
this path (PDFCreatorOption.AutosaveDirectory := gVATReportSetup."VAT Path Destination") is network address whit everyone all permission and if i try to use PDF creator whit same configuration manually, it work perfectly.
Please, can anyone help me?Giorgio Gandolfi0 -
To Set a Printer, f.e. Bullzip, as Defaultprinter u can use dhe rundll32
IF ISCLEAR(WSHShell) THEN CREATE(WSHShell); WSHShell.Exec('rundll32 printui.dll,PrintUIEntry /y /n "Bullzip PDF Printer"');
Do you make it right, it works too!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