Setting PDF Filename when using Print Preview

Normally when I want a PDF generated from a report I do so by using the iDestination function, similar to this:

2015-04-13_0733

The generated PDF will have the name specified by the variable PDFFileName.

But recently a Client had a report that we were using the Print Preview for, however when the user saved the report as a PDF from the Print Preview window, we still wanted to set a default name for the PDF file.

The search for this feature, turned into a prime example of what working with WX is like. I was confident that they would have such a feature, I just had to figure out what the function name was.

After review the help for several print function, I finally found the right one iParameterExport

Along with being able to specify the name of the generated files from print preview, this function also allows you to specify options related to emailing from print preview.

So after researching the various options, our print code now looks like this

2015-04-13_0758

We are using iExportEmailRecipient to set the Recipient of the email if the supplier has an email on file.

We are using iExportEmailSender to set who the email comes from, we have a configuration that allows for various documents to show as coming from different senders.

We are using iExportEmailSubject to set a default subject line for the email, in this case, the company name and purchase order number.

We are using iExportFile to set the default name of the resulting PDF (or excel, word, etc) file, if the user chooses any of those options from the print preview.

Note these settings only effect what happens if the user selects those functions from the print preview, we are still sending the report to the report preview via the iPreview function.

There are two other options of iParameterExport that we are not using

iExportDirectory sets the directory that the file will be generated in. This would seem to be a great feature, and we even have a configuration setting that would supply this value. However if you configure this value, then PDF button from the Print Preview just generates the PDF using the name and directory provide and ask if you want to open it. It does not all the user the opportunity to override the destination or name. Making this setting not as useful as I would like.

iExportOption sets various confirmation options for Overwriting the file, etc. Which would be useful in combination with iExportDirectory, but none of the combinations gave me what I wanted which would be to allow the user to override the default location and name.

As we have it configured, when the user presses the PDF button from the print preview, they see this window, which has the name of the PDF as we set it, and is offering to save it in the same directory as the EXE that is running.

2015-04-13_0757

And when the user presses the email pdf button in the print preview, their default email client comes up with the Sender, Receiver, and Subject lines already specified.

2015-04-13_0756

Note: As mentioned the hardest part of this task was finding the WX function, which would have taken much longer without using Google’s Site Search function.

Now, back to your regular schedule program….

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s