|
I know Acrobat 7 has a Create PDF button and menu item, but that feature only allows for the conversion of existing files to PDF. What happens if you want to create a new PDF, but don’t have a source file to begin with?
If you don’t use the following trick, you have to leave Acrobat and create a PDF from some other application. Before I learned this procedure at a PDF Conference, I always kept a PDF around called Blank Page.pdf.
I use this new menu item for two things. First, I use it when testing new JavaScripts. Because I’ve created this document from scratch, I know it doesn’t have any old code floating around that might foul up my new code.
Secondly, there are times when I am assembling a PDF from different files, and I need to insert a blank page to fix the pagination.
Before Acrobat 7, you simply had to write two lines of JavaScript to add the item to the File menu to generate a blank, 8.5- by 11-inch page. Adobe has increased the security in Acrobat 7 to protect against malicious JavaScripts, so you now need to know the magic word to add items to menus via JavaScript. Although I often run this script without doing so, you can turn on Edit | Preferences | JavaScript | Enable menu items JavaScript execution privileges to help ensure that it runs.
The magic word is app.trustedFunction. I know, it’s as obscure as abracadabra, but now you know the password. You'll see app.trustedFunction in the procedure bellow.
Although the new security level makes it more difficult to add menu items to Acrobat, Adobe makes it very easy to implement the File | New enhancement. To add this feature to your File menu in Acrobat 7, follow the steps below.
- If you don’t have it already, download the Acrobat JavaScript Scripting Reference from partners.adobe.com. Be sure you have the JavaScript reference for Acrobat 7.
- Turn to the bottom of page 119 and look for the script beginning:
trustedNewDoc = app.trustedFunction( function (nWidth, nHeight)
- And on page 120 ending:
+"trustedNewDoc(nWidth, nHeight) "});
- Copy and paste the entire script into your favorite text editor. Notepad works just fine for this. Word does not.
- Save the file as NewMenuItem.js.
- Make sure Acrobat is closed.
- Paste NewMenuItem.js into the JavaScripts folder in your Acrobat 7 installation, which is probably located at C:\Program Files\Adobe\Adobe Acrobat 7.0\Acrobat\Javascripts.
- Start Acrobat.
You should now have a New menu item in your File menu, and options for Letter, A4, and Custom… .

To create a new PDF, just choose one of your new File | New options, and a blank PDF will appear.
Note: The Custom… option takes measurements in points. There are 72 points to an inch, so a 72- by 72-point PDF will be one inch square. You can even use the Custom… option to create a 1- by 1-point PDF.
Have a comment on this article? Send E-mail to info@pdfconference.com.
|