Creating PDF automatically

Hi! I am looking for some code examples of how to use Adobe PDFWriter to automatically create PDF Files. Alternatively, any assistance with Amyuni’s Software would be greately appreciated. Darren Bezzant, NCPS, NCSD

I can recommend Amyunis PDF Converter. Very reliable and flexible. Not vrey expensive either if You by the developers edition. Below is an example for sending an order confirmation. First You install the PDF Compatible printer driver on each workstation and on the Citrix server if You use Citrix. TempDir := ENVIRON(‘TMP’); IF TempDir = ‘’ THEN TempDir := ENVIRON(‘TEMP’); IF TempDir = ‘’ THEN ERROR(‘Uneble to access tempdir.’); TempDir := TempDir + ‘’; CLEAR(pdfConverter); CREATE(pdfConverter); pdfConverter.DriverInit(‘PDF Compatible Printer Driver’); pdfConverter.DefaultDirectory(TempDir); pdfConverter.FileNameOptions := 1+2; pdfConverter.DefaultFileName(TempDir + SalesHeader.“No.” + ‘.pdf’); SalesHeader2 := SalesHeader; SalesHeader2.SETRECFILTER; pdfConverter.SetDefaultPrinter; REPORT.RUNMODAL(REPORT::[Your report name],FALSE,FALSE,SalseHeader2); pdfConverter.RestoreDefaultPrinter; After this You use standard MAPI-functions to create an email and attach the pdf. Hope that helps //Lars

As an alternative, you could consider Acrobat Distiller instead of PDFWriter. Distiller scans a folder periodically for postscript files to RIP. For more details, e-mail me.


Originally posted by Lars Westman: I can recommend Amyunis PDF Converter. Very reliable and flexible. Not vrey expensive either if You by the developers edition.

This approach involves using a printer driver which writes the output of a report to a PDF file instead of actually printing it. This is the best way to create PDF files from Navision data IF you can be confident that the printer driver will in fact be present on users’ systems. The problem with this approach is that in most cases, you will be dealing with customer organizations which do not have a good system for making sure that the printer driver is in fact installed correctly. Also, most organizations will try to wriggle out of paying for a site license for Amyuni’s software. The same problem would apply if you tried to use Adobe Distiller. ------- Tim Horrigan

I recommend using Acrobat Distiller. It’s flexible and powerful enough for documents circulation automation. You can see the C/AL code example at the link below: 

Regards, Yuri Pokusaev IBS, Senior Consultant NCPS, NCSD +7(095)987-8080

Hi, We have downloaded the AMYUNI PDF Converter DEMO and trying to replicate the code that Lars has entered previously. We have pdfConverter as Automation (correct ?) but when you look at the C/AL Symbol Menu (F5) we don’t see FileNameOptions or DefaultFileName. Is this right ? Thanks

Robin, I think you look at Methods in the C/AL Symbol Menu but if you look at Properties in the C/AL Symbol Menu you can see FileNameOptions and DefaultFileName. Bjarne

Hi Bjarne, Many Thanks. I obviously didn’t look hard enough. Robin

Moved from “Attain Developer Forum” to “Attain Developer FAQ” forum.

With PDF being standard in Reporting Services and 5.1 I was wondering if anyone knows if we can also automate reports to be saved as PDF reports without actually opening the preview and selecting save as PDF file? I mean is it possible to create a report and print it to PDF in the background and then attach it with an email…

Reporting sevices includes e-mail delivery capability a report to a group of users. The report can be embedded or attached.
Are yor refering to this ?

Actually I wanted this to be managed directly from within NAV - i.e. you create an invoice report you want to be sent automatically to the customer based on the customers email address on the customer card.

Altus have a solution, that I have heard good things about, but I have not actually tried it out.

Not quite the answer I was looking for.

In my previous job we also developed this as a part of our solution. So yes it can be done today. And properly also with the new 5.1 “role based client”. But my question was more in the direction. Will this be “standard” or build in functionality to automatically create and send a PDF file?

I actually have another question in the same area. How does 5.1 handle reports if you are using the “C/SIDE client” opposed to the “role based client”? I mean will the “C/SIDE client” also be using reporting services?

C/Side client will still use the old reports just like 4.0 or 5.0

So organizations who decide to run both the C/SIDE client and the role based client, needs to set of reports! [:^)]

Not very smart in my opinion!

Yes, reports based in reporting services will only run in platform.

Hi Erik,

the Enterprise edition of SQL Server Reporting Services has something called data-driven subscriptions (this also exists in the Developer’s edition so you can have a play with it - although be careful to ensure your client has the correct version.)

The data-driven subscription allows you to do just what you were talking about - that is on a pre-determined schedule, you can run a SSRS report using parameters (such as render format, e-mail address, delivery method and report parameteres) that are returned by any SQL statement (such as a stored procedure or simple select statement.)

The tricky part is stopping the report from running (since your subscription would be set up to fire every few minutes looking for a report to send) as you don’t want it to go more than once. You can do this by including a unique ID on your table that stores the reports that need to be sent and passing this as a parameter to the report. The report will then have a dataset that updates the table by setting a sent flag - thrus preventing it from being picked up the next time the subscription fires.

You should be aware that just because a report is rendered in this way is no guarantee that it got delivered or even sent. Although, this is by far the easiest way of acheiving the requirement with no “heavy” programming.

The Reporting Services web-service API allows you to render reports in any format you choose from within .NET code so you could certainly use that and write your own render and delivery code quite easily in .NET.

As to whether you will be able to do all of this in version 5.1 really depends on how MS are planning on implementing SSRS reports in Dynamics NAV 5.1. In CRM, they write reports from a series of views that are very complex, slow and do not allow more than a few views to be joined. The reports get imported into the CRM app. which allows the reports to be called from within the CRM UI and for pre-filtering to take place. These reports expect to be run from within the CRM environment and are looking for a Windows user ID that exists in the CRM permissions table. This makes things a little more complicated since SSRS reports can only run on a subscription basis if the datasource has stored credentials - not impossible but just a little harder than it needs to be. It is possible that the NAV reports are going to use a custom data-provider rather than hitting the standard SQL objects or Custom views. I wish I knew how it was going to work but I guess we don’t have long to wait to find out.

hi lars

tell the variable type of (pdfConverter) or Automation object its using