Automate PDF File Creation in WordPerfect

By: Gordon McComb

You already know WordPerfect is the best solution for writing, editing, and printing documents. But thanks to its new PDF creation tools, you can count on WordPerfect to be the best tool for building all your feature-rich PDF files

Have you had a chance to use WordPerfect’s Publish to PDF feature? With it you can rapidly build any PDF document simply by selecting the publishing options you want, and giving the file a name. Click Save, and you’re done.

It gets even better! Now in WordPerfect X7, you can automate all the steps to PDF document creation using handy macros. Standardized PDF options can be conveniently set inside the macro – no more specifying the publishing options each time, or remembering to first choose a predefined settings style.

What’s more, the finished PDF files can be “automagically” saved in folders of your choice, without human interaction, using filenames that follow any criteria you set. Your PDF documents can now be standardized just the way you want them, and it doesn’t require additional user training or effort.

If you’ve been looking to streamline your PDF document building, you’ve just found it!

In this article, I'll show you how to combine WordPerfect's PDF and macro features. You'll learn the basics of publishing to PDF and using PDF styles. You'll create your first macro that generates a new PDF using the current WordPerfect document.

Using WordPerfect’s Publish to PDF Feature
Before talking about automating PDF document creation, let’s quickly review WordPerfect’s general PDF publishing features. The steps to creating a new PDF file are simple:

  1. Start with any WordPerfect document. Specialized document formatting is not required – you don't have to use specific styles.
  2. Choose File→Publish to PDF. A file save dialog box appears. Provide a file name and select a folder for storing the document, then choose Save.

    Tip: If you’ve already named and saved the current WordPerfect text document, that filename – but with a .pdf extension – is automatically provided for you. Keep this name, or specify another. You can use the auto-naming feature to correlate your PDF files with their source WordPerfect documents.

  3. While in the PDF save dialog you may select options that specify numerous PDF settings, including security permissions, passwords, and quality. While in the PDF file save dialog, click the Settings button; this displays the Publish to PDF Settings dialog. Choose the options you want, and choose OK.
  4. Click Save to generate the PDF. WordPerfect displays its progress as the PDF document is created for you.
    After the PDF is generated, you may view it in your favorite PDF reader, such as Adobe Acrobat or Foxit. If you ticked the Open PDF After Saving option in the PDF save dialog, your newly created document is automatically opened in the reader.

Saving Time With PDF Styles
Setting the same publishing options each time you build a new PDF file is time consuming and prone to error. So WordPerfect allows you to set your own settings styles – these styles include most* of the options you’ve specified in the Publish to PDF Settings dialog.

* Not all PDF publishing options are stored in the style. A few, such as the Export range, are intended to be manually set each time.

WordPerfect comes with several PDF publishing styles built-in. You may use these styles as-is to publish your PDF documents, or as starting points for your own custom styles.

  1. Change the options in the Publish to PDF Settings dialog to the ones you want.
  2. Return to the General tab, and click on the + button beside the PDF styles drop-down list.
  3. Provide a short but descriptive name for your new style set, and choose OK.

Your newly created PDF publishing style is stored and selected for you. WordPerfect will remember the selection until you change it again. If you no longer need a custom style: select it in the PDF style list, then click the - button. Note: You cannot remove WordPerfect’s built-in PDF styles.

Tip: Wondering what all the PDF publishing options do? Space doesn’t permit describing them all here, but you can read about the options by clicking the Help button in the Publish to PDF Settings dialog box.

Automating PDF Output With a Macro: The First Steps
You can use a WordPerfect macro to replicate the manual steps of setting a PDF style and generating a PDF document. Let’s explore this technique by recording such a macro, then opening it to see what lurks inside:

  1. Create a simple WordPerfect document – just a sentence or two is all you need.
  2. Start macro recording by choosing Tools→Macro→Record.
  3. Type MyFirstPDF as the name of the macro, and click the Record button. Now, everything you do in WordPerfect is being recorded.
  4. Choose File→Publish to PDF.
  5. In the PDF Style list, choose the built-in Publishing Online and Printing style.
  6. Navigate to your usual Documents folder (if you’re not already there), and type MyFirstPDF as the PDF filename. Click Save.
  7. Choose Tools→Macro→Record once more to turn macro recording off.

With the macro recorded, open it for viewing by choose Tools→Macro→Edit. Click on the MyFirstPDF file, and choose Edit. The macro opens as a WordPerfect document. Here it is:

Application (WordPerfect; "WordPerfect"; Default!; "EN")
PdfDlg ()

Doesn't look like much, does it! In fact, if you played back this macro, all it would do is display the PDF save dialog. It won't automate your style choice, or save the PDF file using the name and location you provided. This information is simply not stored in the recorded macro.

Enhancing Your PDF Output Macro
But fear not: you can easily modify your recorded macro to specify a save location and filename, as well as the PDF publishing style.

Create a PDF style you wish to use.

  1. Choose File→Publish to PDF, and click on Settings. (Reminder: Your document must contain at least some text for the Publish to PDF command to be available.)
  2. Choose the Publishing Online and Printing PDF style.
  3. Make a simple change in the PDF options. A good one is to select the Document tab, and click Full Screen for the On start, display option.
  4. Go back to the General Tab, and click the + button beside the PDF style pull-down list.
  5. Type MyStyle, and choose OK.
  6. Tick the Open PDF After Saving option.
  7. Choose Save to generate the PDF.

Tip: Some PDF viewer programs will display an advisory if the document is set to automatically display in full screen mode when first opened. Simply click OK or Yes to proceed.

Next, modify the MyFirstPDF Macro.

Open it for editing as detailed above, then change it as shown here.

Application (WordPerfect; "WordPerfect"; Default!; "EN")
PDFStylesSetActive("MyStyle")
PdfDlg (?PathDocument + "MyFirstPDF.pdf")

Double-check that your revisions look exactly as shown. Don't forget the double-quotes: missing these or putting in too many will prevent the macro from running.

Here's what the changes do:

  • The PDFStylesSetActive command specifies the PDF style set you wish to use. In this case, it's MyStyle, which you created in the steps above.
  • The text added to the PdfDlg command specify the location and filename of the generated PDF. The ?PathDocument statement is a shortcut to your Documents folder. The macro uses this shortcut, and the MyFirstPDF.pdf filename, to precisely locate where to store the PDF document.

Compile the macro with your new changes.

Click the Save & Compile button in the Macro Toolbar.

Tip: If there are any errors in your changes, WordPerfect will flag them with a warning. You need to fix any mistakes that crop up, and then click the Save & Compile button again.

Run the macro to verify your changes.

You can run the MyFirstPDF macro using any of the following techniques. You don't need to close the macro to run it.

  • Click the forward-arrow (Play) button in the Macro Toolbar.
  • Choose Tools→Macro→Play, highlight the MyFirstPDF macro, and click Play.
  • Press Alt+F10, highlight the MyFirstPDF macro, and click Play.

View the generated PDF document.

After the macro has finished running, the PDF document is generated, and should automatically open in the PDF viewer program.

Tip: WordPerfect knows if your generated PDF document is about to overwrite an existing file. If you run the macro again without first deleting the MyFirstPDF.pdf file, you will be prompted whether you wish to overwrite it. Click Yes to proceed. Next month I'll show you how to avoid this warning message and automatically any existing file.