Skip to main content

Generating PDF Files with Print Wizard

Introduction

Print Wizard version 3.0 has the ability to produce PDF compatible files from a number of different sources with a number of differing options. In this article, we hope to describe some of the various options available and make you aware of the capabilities of Print Wizard and PDF generation.

Printing a Local File to PDF through the User Interface

Print Wizard’s User Interface program allows you to select a file to perform a print option on. Using the File menu’s Open File, you can select any local file that Print Wizard can print and generate a PDF for it.

The exception to this procedure is that Print Wizard must be able to print the file normally in order for Print Wizard to generate the PDF.

Within the User Interface, select a file through the File menu’s Open dialog. Next click on the toolbar item for PDF generation (the one with the “A”), or select the File menu item “Generate PDF…” where you will be acted for the output file name. Here you can also select what to do with that file, such as view it or email it.

 

You can also select which directory you want to place the file in or browse for the directory by clicking the ‘…’ browse button. Once you are done, click on the ‘Generate’ button.

If you had checked the “View generated file” your Windows default PDF viewer (usually Acrobat Reader) will popup. If you have selected “Email generated file”, the following dialog pops up and asks you for pertinent email information.

 

Printing a Local File to PDF from your own Script or Application

The Print Wizard engine is what does the real work in generating PDF files from your own print files. You can incorporate this directly into your own application or script file. This is easily done by using command-line parameters.

With these command-line parameters, you list the file name and the options and the PDF file will be generated. These command-line parameters can specify the directory, the file name, whether it should be unique and whether to view it.

printwiz.exe /fpdf://?

printwiz.exe /fpdf://? [/f…]

printwiz.exe /pdf

printwiz.exe /pdf /f

Additional command line options related to PDF generation include     

/protect            Leave an existing PDF file name in place and rename the new file
                        (protect the old, rename the new)

/rename            Rename the existing PDF file if it exists and use the new name

/q                     Run quietly, automatically generating PDF file names
                        (without this, Print Wizard will ask the user for the name)

If you list multiple files on the command line and you wish to produce PDF’s for each file with the /fpdf:// option, you will need to include a /fpdf:// command for each file. If you use the /pdf option, all files are assumed to be generated as PDFs.

The easiest way to see the possibilities is with some examples:

printwiz.exe /fpdf:// file1.txt
            o Print Wizard asks the user for an output name and generates the PDF file

printwiz.exe /fpdf://?c:\temp\ file1.txt
            o Print Wizard asks the user for an output name and generates the PDF file
            starting the save as dialog in the c:\temp\ directory

printwiz.exe /fpdf:// file1.txt /q
            o Print Wizard runs in quiet mode and with a default of overwrite to overwrite
            any existing output files. Print Wizard does not ask the user for an output
            name, but generates the PDF file name based on the input name. By default
            it takes the name portion of the file and replaces the extension with ‘.pdf’.

For automatic generation of PDF files with Print Wizard (running in “quiet” mode), the default is to always overwrite the existing file.

printwiz.exe /fpdf://c:\temp\ file1.txt /q
            o Print Wizard runs in quiet mode, generating a file name in the c:\temp\
            directory based on the original file name.

printwiz.exe /fpdf://c:\temp\myfile.pdf file1.txt /q
            o Print Wizard runs in quiet mode, generating a file name in the c:\temp\
            directory based on the “myfile.pdf” name, overwriting it if it exists.

printwiz.exe /fpdf://c:\temp\myfile.pdf file1.txt /q /rename
            o Print Wizard runs in quiet mode, generating a file name in the c:\temp\
            directory based on the “myfile.pdf” name. If that file name already exists,
            Print Wizard will rename it and use the “myfile.pdf” as the new file name.

printwiz.exe /fpdf://c:\temp\myfile.pdf file1.txt /q /protect
            o Print Wizard runs in quiet mode, generating a file name in the c:\temp\
            directory based on the “myfile.pdf” name. If that file name already exists,
            Print Wizard will generate a new name starting at  “myfile0001.pdf” as the
            new file name.

printwiz.exe /fpdf://c:\temp\  @filelist.txt /q
            o Print Wizard runs in quiet mode, generating a PDF file name
            in the c:\temp\ directory for each file found in the filelist.txt file where one file
            name is listed per line. Names generated will be based on the original file
            name.

printwiz.exe /fpdf://c:\temp\myfile1.pdf  /fpdf://myfile2.pdf  file1.txt file2.txt /q
            o Print Wizard runs in quiet mode, using myfile1.pdf for file1.txt in the
            c:\temp\ directory and using myfile2.pdf for file2.txt in the default working
            directory (note that there is no directory listed on the second /f option).

printwiz.exe /fpdf://?view file1.txt /q
            o Print Wizard runs in quiet mode, generating a file name in the working
            directory based on the original file name. It then brings the file up in the
            Windows default PDF viewer for the user to see.

printwiz.exe /fpdf://c:\temp\?view file1.txt /q
            o Print Wizard runs in quiet mode, generating a file name in the c:\temp
            directory based on the original file name. It then brings the file up in the
            Windows default PDF viewer for the user to see.

printwiz.exe /fpdf://?Title=features?Author=Joe?Subject=somestuff?Keywords=abcdef file1.txt /q

            o Print Wizard runs in quiet mode, generating a file name in the current
            working directory based on the original file name. It then assigns a Title,
            Author, Subject and a Keyword to the document.

Check with us on more options as they become available.

Printing a Remote File to PDF using Windows Services for Print Wizard
or Print Wizard Services

Setting a different spawn job
Services for Print Wizard are a set of services that can be ran through the Windows services platform (making them available at all times as long as the PC is up, even when no user is logged in), or ran as a separate, stand-alone service program. When a file is received by one of these services they fire off the Print Wizard engine. The Print Wizard engine can then be set to run with specific command line parameters, such as

   printwiz.exe /fpdf://c:\temp\myfile1.pdf /protect

When you set up the service, you can override the service “spawn” job. When blank, the service runs the Print Wizard engine, printwiz.exe, with default settings. You can override the default by entering in your own spawn command. Be sure to include a full path name however.

In the case of Windows Services for Print Wizard, you always want to be sure to include a /q on all changes that use Print Wizard since there is no user interaction available when running as a Windows service.



Setting a Print Profile
In addition to this approach, you may also point a service entry to a Print Wizard Profile. In this print profile, you can specify a default action to take of always generating a PDF file, similar to running the spawn job.

Under the Tools menu, setup the Profile with a Target of Generate PDF and then select any necessary options from the Print Wizard tab, such as generate-then-email or generate-then-view.

Printing a Remote File to PDF using the Print Wizard Engine

The Print Wizard engine itself is designed to run both a despool and a listen service without the need for setting up any service records or profiles. While this is not the recommended method, it is available for backwards compatibility.

To do this you would simply include a /despool or a /listen command line option. In doing so, you need other parameters as well. An example may best describe this:

printwiz.exe /despool c:\temp\pw-despool\ /fpdf://

This will watch for any files in the \temp\pw-despool directory and print them with the /fpdf:// option, with all the options and capabilities mentioned above.

Likewise, the /listen will listen for files on a particular port and create PDF files for any received:

printwiz.exe /listen /fpdf://

Files will be received over the default port 9100 and printed to PDF. For more information on either of these options, check out the Print Wizard documentation.

Since a “listen” type service has no associated file names, the default file name when automatically generating PDFs (quiet mode) is    Printwiz_Output.pdf    in either the current working directory or the directory listed in the /fpdf:// command.

If you want the user to be asked for a file name each time, you can do so by NOT including a /q.

It is important to note that when you run the Print Wizard engine with /listen or /despool, the default overwrite is to always “protect”. This is controlled by an option in the default file, printwiz.ini, that does not have a related menu or dialog item in the user interface. You can manually change this setting if you want by opening the printwiz.ini file with Notepad and editing the line “svcoverwrite”. Your three options are “protect”, “rename” or “overwrite”:

runthreshold=0
svcoverwrite=protect
historysize=25
jobprofile=C:\printwiz301\pwui.job

If you are running in quiet mode with a /q, with /rename or with the default option set to overwrite in the default printwiz.ini file, and you include a ?view, and you receive a new file with the PDF viewer already open, you can run into file conflicts. We recommend you run in these cases as /protect in order for Print Wizard to always be able to generate a new file.

Conclusion

There are lots of options when it comes to generating PDFs and even within Print Wizard there are many options. A little bit of planning and understanding of file collisions, makes setting up Print Wizard simple and flexible.

As always, for any specific needs, feel free to contact us at rsi@anzio.com .

 

Copyright © 2024 Rasmussen Software, Inc. Legal Information & Privacy Policy
Send comments and suggestions to rsi@anzio.com