Using the XPS driver

The PDF printer was originally based on converting the output from Postscript drivers to PDF. This way of doing it has served the purpose well for a long time. However, sometimes the output can convert in ways that do not serve the end purpose well.

Especially font issues have been a reason to look for alternatives to the Postscript driver technology. Postscript has built-in fonts and different strategies for embedding subsets of fonts which may not work well with software that tries to read or copy/paste the content of PDF documents.

To fix some of the Postscript related issues we have added the option to use an XPS based driver. The functionality of the XPS based approach supports fewer features but it solves some of the other issues.

You can tell the installer to add a PDF printer based on an XPS driver by adding the /XPS switch to the command line of the setup program.

The following command line is an example that shows how to add an extra PDF printer named “PDF Printer (XPS)” to your system.

Setup_BullzipPDFPrinter_14_4_0_2963.exe /XPS /PRINTERNAME="PDF Printer (XPS)"

The new printer will ask the printing application to print using an XPS based driver and convert the output to PDF.

 

Upload PDF via (S)FTP or HTTP(S)

The PDF Printer has a feature that will upload the created PDF file to a server. Both FTP and HTTP uploads of the PDF document are supported. This means that you can send the documents to a web server that you have created and do some processing in a cloud application.

Uploading to an FTP or SFTP server is simply a matter of setting up a server to receive the files.

HTTP and HTTPS are supported via the normal file upload protocol. It requires that you create a script on your server that will receive the uploaded file.

You can test your upload script by creating a simple “File Upload” form on a web page. The code could look something like this:

<form action="upload.php" method="post" 
    enctype="multipart/form-data">
    Select file to upload:<br>
    <input type="file" name="file" id="file"><br>
    <input type="submit" value="Upload File" 
    name="submit"><br>
</form>

The page that receives the file can be written using any web server language. Here is an example in PHP.

$filename = basename($_FILES["file"]["name"]);
if (move_uploaded_file($_FILES["file"]["tmp_name"], 
    $filename.".tmp")) 
{
    // This file is copied so that IIS 
    does not set itself as owner of the file.
    copy($filename.".tmp", "uploaded-".$filename);
    unlink($filename.".tmp");
    echo "The file '".$filename."' was uploaded.";
}
else
{
    echo "Error";
}

Configure the printer for upload

You can tell the printer to upload to your HTTP handler by adding these settings:

uploadprotocol1=HTTP
uploadserveraddress1=http://yourserver/your_script.php

Additional parameters are available for setting password and user name if needed.

http://www.biopdf.com/guide/settings.php

The upload settings can be set from a program using the API or in the global.ini files that control the global settings for a printer.

http://www.biopdf.com/guide/global_ini.php

This an example of typical settings to set when working with an upload scenario.

Output=my output file name
ShowSettings=never
ShowPDF=no
ShowProgress=no
ShowProgressFinished=no
ConfirmOverwrite=no
StatusFile=my status file name
StatusFileEncoding=unicode
DeleteOutput=yes
suppresserrors=yes
uploadprotocol1=HTTP
uploadserveraddress1=http://localhost/test/upload.php

Printing Preferences vs. Printing Defaults

When printing, you will encounter a couple of places where you can change the printer settings. Two of these places are found in the printer’s property dialog.

On the General tab, you can click the Preferences button and change the printer settings for the currently logged in user. This means that you can change your own settings for this specific printer. The changes that you make here will not affect other users.

If you go to the Advanced tab and click the Printing Defaults button, then you will see a similar dialog. However, this time you are looking at the settings on a machine level. This means that when you change the settings here it will affect the users that don’t yet have their own preferences set.

New users will inherit the settings from the Printing Defaults.

Sometimes, the user’s preferences are reset by Windows. This can happen during Windows updates, reinstallation of the printer, or GPO changes. Other events may also reset the settings.

Background PDF Problems

Using a PDF as a background can sometimes cause problems. PDF documents are created in a different way by a variety of applications. It happens that these PDF documents are not compatible for use as a background or watermark PDF. Especially PDF documents created by Adobe products have incompatible color models or other advanced unsupported features.

The problems can result in different types of errors. Sometimes the colors are not correct and other times you will get a blank page followed by a page with cryptic error information.

This is what the error page could look like:

ERROR:
typecheck
OFFENDING COMMAND:
repeat
STACK:
--nostringval--
-mark-
-mark-
-mark-
-mark-
-mark-
-mark-
-mark-
-mark-
-mark-

Solution

The solution is to print the background PDF to a new PDF using the PDF Printer. You can try to print it using different PDF viewers. They have different ways of printing the PDF and the resulting PDF will have different properties depending on the viewer that printed it. Usually, you can create a working background PDF this way.

I suggest that you try to print it from the following PDF viewers:

Bullzip PDF Studio

SumatraPDF

Adobe Reader

Printing to PDF from Firefox or Chrome

Firefox and the Google Chrome browser renders print jobs as graphics instead of text. This means that the PDF Printer does not see the actual text that is printed but only a picture. Therefore, you cannot copy and paste text from a PDF printed from Chrome.

You can use Microsoft Edge to print your web page and get a PDF with searchable and copy/paste capabilities.

 

Print to printer and PDF at the same time

With the PDF printer, you can send the newly created PDF to a real printer after the PDF is saved. This enables you to implement a workflow where you create a PDF archive of all your print jobs.

This post will show you how to create such an archive printer as a separate printer on your system.

First, you download the latest PDF printer and install it from a command line with the following command line switches:

Setup_BullzipPDFPrinter_11_1_0_2600_PRO_EXP.exe /SILENT /PRINTERNAME=”Archive PDF Printer”

This will install a new virtual PDF printer on your computer. The new printer is named “Archive PDF Printer”. After the installation has completed, you can use this printer as a normal PDF printer.

We need to configure it to send all print jobs to a PDF archive folder and to another real printer. This is done with the global.ini file in this location:

C:\ProgramData\PDF Writer\Archive PDF Printer\global.ini

Open the global.ini in a text editor and add the following lines:

[PDF Printer]
 Output=C:\Archive\<username> - <date> <time> - <guid>.pdf
 ShowSettings=never
 ShowSaveAS=never
 ShowProgress=no
 ShowProgressFinished=no
 ShowPDF=no
 ConfirmOverwrite=no
 PrintToPrinter=yes
 PrinterName=Microsoft XPS Document Writer
 PrinterSelection=Specific

The output setting specifies the name of the saved PDF document. The output name uses macro names that will be substituted by real information at run time. You can see a complete list of macros here:

Click here to see all the Macro tags

All the show settings control the dialog. The settings used here will hide the printing dialog and automatically save the PDF.

The printer settings control how the PDF document is printed to a normal printer.

You can read about more show and printer settings here:

Click to see a complete list of PDF printer settings

Please note that you need the expert edition to send the document to a normal printer.

Split PDF pages in multiple files

You can use the PDF Printer to split a PDF into multiple files. Each file will have one page from the original PDF.

It is as simple as adding the <pageno> macro name to the output file name. Here is an example:

Split PDF

Using the file name “test – <pageno>.pdf” will result in files named “test – 1.pdf” for the first page and so on.

Additional formatting can be added to the page no. If you write <pageno,3> the number will be zero padded to the length of 3 characters. The padding character can be specified as an additional parameter such as <pageno,3,->. This will create a page number like –1, –2, etc.

See the documentation about macros for more information.

Print PDF from Microsoft Outlook

This post contains a VBA macro that will set the output file name to a cleaned version of the subject. The selected mail item is then printed.

Note that Outlook remembers the last printer used. Therefore you have to use the PDF printer before you run this macro. Otherwise, Outlook will just print to another printer.

Option Explicit

Public Sub PrintPdf()
  Dim mi As MailItem
  Dim o
  Dim p As Integer
  Dim subj As String
  Dim illegalchars As String
  Dim i As Integer
  Dim output As String
  Dim settings As Object
  
  For Each o In Application.ActiveExplorer.Selection
    If TypeName(o) = "MailItem" Then
       Set mi = o
       subj = mi.Subject
   
       Rem -- Clean reply and forward prefixes
      Do
         p = InStr(1, Left(subj, 4), ":")
         subj = Trim(Mid(subj, p + 1))
       Loop While p > 0
    
     Rem -- Remove illegeal file  name characters
     illegalchars = "<>:""/\|?*" 
     For i = 1 To Len(illegalchars)
       subj = Replace(subj, Mid(illegalchars, i, 1), "_")
      Next
    
      Rem -- Remove double underscores
      Do
        p = InStr(1, subj, "__")
        subj = Replace(subj, "__", "_")
      Loop While p > 0
    
      Rem -- Create the COM settings object to control the printer.
      output = "C:\Temp\" & subj & ".pdf"
      Set settings = CreateObject("bullzip.PdfSettings")
      settings.SetValue "Output", output
      settings.SetValue "RememberLastFolderName", "no"
    
      Rem -- Write settings to the runonce.ini.
      settings.WriteSettings True
    
      Rem -- Print the object
      Debug.Print "Printing: " & subj
      mi.PrintOut
    End If
    Exit For
  Next
End Sub

When you have created the macro, you can customize your ribbon and give it an icon.

outlook-macro

Excel preview shows many pages but strange or no output

Some Excel sheets show a strange behavior when you print them or do a print preview. This can be caused by the wrong DPI setting for the Excel sheet you are looking at.

It is easily fixed if you change the DPI setting to something meaningful.

First, you click the small icon on the Page Layout tab.

excel page layout

Second, you change the print quality to something like 300 dpi.

excel page setup

Now, you should be able to print your document.

Color problems with a background PDF

Some PDF documents change the colors when they are used as background for another PDF. This is often the case for PDF files created with other tools where the color information is not fully compatible.

Print PDF to a new PDF with Bullzip

You can often get the colors right if you print the existing background PDF to a new PDF using the Bullzip PDF Printer. Simply open the background PDF in Adobe Reader and print it to the Bullzip PDF Printer. Then use the new PDF as the background PDF.

If this doesn’t work, you can try the same procedure with at different PDF viewer. Instead of Adobe you can use Bullzip PDF Studio or Sumatra PDF Reader, which are free readers available for download on the Internet. This has often produced good results.

PDF Compatibility Level

You can also try to change the compatibility level of the PDF that you create. This can also be used when you create the background PDF by printing it from another reader as mentioned above.

PDF Color Model

In the PDF options dialog, there is an option to change the color model used, when creating a PDF. Try to experiment with that as well.

Hopefully, one of the strategies mentioned here will help you solve the color issue when using another PDF as a background. These methods should all preserve the vector based information intact and deliver the best quality possible.