Simplicty and flexibility!


Sample in DE8 - Print to PDF with Filename

Started by DataEase
You will need to Sign In to be able to comment on the Blog!

Sample in DE8 - Print to PDF with Filename

Download Sample


We made a small sample to show how to do this some time back, but I think it was so long ago that it was not published on this forum...

In DE8 we removed the built in PDF printer as it was never fit for purpose and it never worked in x64. In stead we took a leaf out of the DFD book and re-implemented Application Printers.

Application printers is 4 printer viritualization objects that you can use to direct your print output to 4 local printers without having to change it in the Document.

You find the Application Printers in Design Mode/Application/Define Application Printers

This means that you can install your own PDF printer and reference it directly in your documents like an internal PDF printer.

The benefit compared to having the previous built in PDF printer is obvious. For one you can make sure you get one that works, or you can use one that you have already bought/downloaded and know. You can also get one with the features you want.

The first part of the DE8 project was to implement new functionality, and our goal was more to get that functionality implemented rather than making it "fool proof". DataEase is supposed to be easy, but this "mantra" started to become a problem when things were removed or let out because it couldn't be "fool proof".

We opted for a different approach and that was that we have to be able to fix it one way or the other, than we can make sure that it is easy to do later. Most DFW developer has spent the last 20 years trying to work around the short-comings of DFW and we have seen some impressive workarounds, so when they can do it without us, we are sure that it will be easier to do it with us... ;-)

Our job is to give you the tools and give you inspiration on how to use them, not to decide how and what you use them for.

So how do you do it:

1. Download and install the free Bullzip PDF Printer from here.
http://www.bullzip.com/products/pdf/download.php

The feature we will take advantage of in BullZip is that it can be forced to print directly to the same file each time, and that this file name is stored in a .ini file.

Mine is located in: C:\Users\Ulrik\AppData\Roaming\PDF Writer\Bullzip PDF Printer\settings.ini

So yours should be located in the same path but with your username instead of Ulrik.

2. Open the sample you downloaded and go to PDFSettings form.
Update the output catalogue and BullZipSettingCatalogue to the correct values.
In Settings you will see "my" entire BullZip Settings file.

output=[{filename}]

And this little line is the clue. What we do in the form is to replace the [{filename}] tag with MemoReplace() and save the Ini file back to the catalogue before we simply print the report to the ApplicationPrinter1.

Simples!

3. Open the Application/Define Application Printers and choose BullZip as Application Pritner one as in the image above.

You are now ready to test the solution out.

In the form Print Test (Messy) you will see it in clear (all the supporting fields can be hidden of course) and it can also be done directly in a ExecDQL dql etc (But that is for another day).

Simply type in a file name (MyFilename.pdf) in the Type in filename here and you will see that the Settings Memo is updated with your Filename. It will now also have been saved to the ini file by virtual field SaveSettingsNewFileName.

When you hit PrintToPdf you will get the PDF saved to the file name.

You can of course do this much more elegantly, but we want to keep it in the open so the different steps are visual.

You can use SetState("Objectname","State") to show/hide the fields you don't want to see.


Written by DataEase 10/09/13 at 08:13:12 Dataease [{8}]FIVE