PDF

Printing Multiple Word Documents to a Single PDF

|

Introduction:
This article contains code which will print all open Word documents into a single PDF file.

These code examples are built for PDFCreator, an open source PDF writer utility. Unlike Adobe Acrobat and CutePDF, which both require pro versions to create PDF's via code, PDFCreator is completely free! Download PDF Creator from Sourceforge here. Please note that this code will NOT work with Adobe Acrobat.

It should also be noted that the example in this section use an Early Bind. If you are not familiar with the difference between Early and Late Binding, please read my article on Early vs Late binding.

Print To PDF Using Microsoft's PDF/XPS Add-in

| |

Introduction:


This article contains code that can be used to print worksheets or entire workbooks to a PDF file, using Microsoft's free Save as PDF or XPS add-in for Office 2007. These routines will NOT work in versions of Office prior to 2007. If you are running an earlier version of Office, and are running on Windows XP, then have a look at my PDF Creator articles.

Versions Tested:


These routines have been tested successfully using the following versions of the software:

Error Messages: User-Defined Type Not Defined

| |

There are a great many errors that we can run into when programming, and just on of those is a Compile Error, specifically "User-Defined Type Not Defined".

This error could mean one of a few different things, which may not all be listed here. Two of the most common, however, are:

1. You are trying to create your own Constants and did not declare the Enum.
For an example of this, see my article on Creating Your Own Constants For Functions

2. You are automating an external program, (using Early Binding,) and forgot to set a reference to the required library.

Error Messages: Can't Initialize PDFCreator

| |

A problem than can occur when working with PDFCreator via code is that sometimes the code releases PDFCreator too early, and it isn't properly closed.

What is happening?
At the end of the PDFCreator routines on this site, we release PDFCreator with (a variation of) the following line:

Set pdfjob = Nothing

As long as the PDFCreator.exe task is (still) running, we'll get the error "Can't initialize PDFCreator." every time we try to run the PDF creation code:

So if you're seeing the above error, the issue is that a PDFCreator process is running on your system. If you opened PDFCreator manually, you may not have closed it. Or, if you had previously run a PDFCreator routine, then it had not finished doing what it needed to do, so the process that was actually running on the system stayed alive. We can check this by going into the Task Manager, (right click the taskbar and choose Task Manager,) and verifying that a PDFCreator.exe task is running.

Printing Access Reports To A PDF File

|

Introduction:
This article contains code examples to print a Microsoft Access report to a PDF file.

This code examples is built for PDFCreator, an open source PDF writer utility. Unlike Adobe Acrobat and CutePDF, which both require pro versions to create PDF's via code, PDFCreator is completely free! Download PDF Creator from Sourceforge here. Please note that this code will NOT work with Adobe Acrobat.

It should also be noted that this code example uses an Early Bind. If you are not familiar with the difference between Early and Late Binding, please read our article on Early vs Late binding.

Print To Picture Using PDFCreator

| |

Introduction:
This article contains code examples to print worksheets to PDF files in a picture format, including: pdf, png, jpg, bmp, pcx, tif, ps (postscript), eps and txt

This code example is built for PDFCreator, an open source PDF writer utility. Unlike Adobe Acrobat and CutePDF, which both require pro versions to create PDF's via code, PDFCreator is completely free! Download PDF Creator from Sourceforge here. Please note that this code will NOT work with Adobe Acrobat.

It should also be noted that each of the examples in this section use an Early Bind. If you are not familiar with the difference between Early and Late Binding, please read our article on Early vs Late binding.

Resetting PDFCreator Options via Code

| |

Introduction:
This article contains code examples to reset some (but not all) of the default settings of PDFCreator.

These code examples are built for PDFCreator, an open source PDF writer utility. Unlike Adobe Acrobat and CutePDF, which both require pro versions to create PDF's via code, PDFCreator is completely free! Download PDF Creator from Sourceforge here. Please note that this code will NOT work with Adobe Acrobat.

It should be noted that each of the examples in this section use an Early Bind. If you are not familiar with the difference between Early and Late Binding, please read our article on Early vs Late binding.

Some Notes On Developing With PDFCreator

| |

During my course of experimenting with PDFCreator, I ran into a few interesting things. In an effort to help any of you who decide to adapt this to your own use, I thought I'd share those here.

Getting the right download package
All of the code samples provided on the site were tested successfully using PDFCreator 0.9.1, GPLGhostscript.exe download package. Excel versions tested include:

  1. Excel 2003
  2. Excel 2007

I did, however, encounter some issues when testing using the AFPL version of the download package. Specifically, setting the encryption to 128 bit created a file that was corrupted. Personally, I'd just avoid that version, and stick with the GPL version.

Using PDFCreator with security options set

| |

Macro Purpose:
To use PDFCreator to make a PDF that leverages some of their security features. Specifically, we'll create a file that uses:

  1. A "File open" password
  2. 128 bit encryption
  3. Preventing content copying
  4. Preventing modification
  5. Preventing printing

These code examples are built for PDFCreator, an open source PDF writer utility. Unlike Adobe Acrobat and CutePDF, which both require pro versions to create PDF's via code, PDFCreator is completely free! Download PDF Creator from Sourceforge here. Please note that this code will NOT work with Adobe Acrobat.

Printing Worksheets To A PDF File (Using Early Binding)

|

Introduction:
This article contains code examples to print worksheets to PDF files.

These code examples are built for PDFCreator, an open source PDF writer utility. Unlike Adobe Acrobat and CutePDF, which both require pro versions to create PDF's via code, PDFCreator is completely free! Download PDF Creator from Sourceforge here. Please note that this code will NOT work with Adobe Acrobat.

It should also be noted that each of the examples in this section use an Early Bind. If you are not familiar with the difference between Early and Late Binding, please read our article on Early vs Late binding.

Syndicate content