Use CutePDF to Print to PDF/A for Free – 2018 Edition

This is a major revision of an article that I wrote in 2013. My paperless workflow creating PDF/A files was doing fine until about a year ago. I was using a modified CutePDF to print browser documents and emails to PDF/A-1b format. But it seems that browsers especially are increasingly using semi-transparent fonts. Since PDF/A-1b doesn’t support transparency, the text was often converting to raster images, which means they appear fuzzy, are not searchable, and the file size increases dramatically.

This workflow now creates PDF/A-2b files, which do support transparency. Fonts are clear again; files are small and searchable. The procedure has also been updated to accommodate more recent Ghostscript parameter settings.

Note This is a fairly advanced procedure and requires Administrator permissions.

CutePDF uses a program called Ghostscript to convert a printer file to PDF. If you don’t already have Ghostscript, CutePDF Writer 3.2 downloads Ghostscript 8.15. But you need a more recent Ghostscript for this PDF/A conversion, so you need to install Ghostscript before installing CutePDF.

1. If CutePDF is installed, uninstall it.

2. Download the latest GNU Affero-licensed version of Ghostscript here (version 9.25 9.54 as of this writing). I found that the 32-bit version works fine even under 64-bit Windows 7. Install Ghostscript but customize the directory so it doesn’t change if you get a later version, I use C:\Program Files (x86)\gs\latest. At the end of the install, go ahead and let it Generate cidfmap for Windows CJK TrueType fonts.

Batch Convert PDFA 1

3. Download the free CutePDF Writer 3.2 here and install it. (Fortunately, Acro Software has removed the adware that they used to install with it). Update 04/24/2021: The latest version is now 4.0 and does not work with this procedure last time I checked. You’ll need to find CutePDF 3.2 somewhere.

The CutePDF installer should automatically find your Ghostscript installation and should not prompt you to download Ghostscript.

4. Create an empty folder on your C: drive called C:\GS_PDFA (Ghostscript PDF/A).

5. Download the Adobe ICC profiles here. An ICC profile describes a “color space.” We’ll use the simplest one, Adobe RGB (1998). From the downloaded zip archive, extract AdobeRGB1998.icc to the C:\GS_PDFA folder.

6. Ghostscript needs some special instructions for creating PDF/A files. These are partially contained in a PDFA_def.ps file. For more information, see the sample file in your Ghostscript installation (C:\Program Files (x86)\gs\latest\lib\PDFA_def.ps).

I’ve modified the sample to reference the AdobeRGB1998.icc file. In the C:\GS_PDFA folder, create an empty text file named PDFA_def.ps and paste in the following text. (Since this a derivative work of a file included with GNU Affero-licensed Ghostscript, please use it under the terms of the GNU Affero General Public License.) (Updated 4/24/2021 based on the sample included with Ghostscript 9.54.)

%!
% This prefix file for creating a PDF/A document is derived from
% the sample included with Ghostscript 9.54, released under the
% GNU Affero General Public License. 

% 04/22/2021 Modified by MCB Systems to use the AdobRGB1998 ICC file
%            located at C:/GS_PDFA/AdobeRGB1998.icc.

% Define entries in the document Info dictionary :
[ /Title (Title)       % Customise
  /DOCINFO pdfmark

% Define an ICC profile :
/ICCProfile (C:/GS_PDFA/AdobeRGB1998.icc)   % Customize.
def

[/_objdef {icc_PDFA} /type /stream /OBJ pdfmark

%% This code attempts to set the /N (number of components) key for the ICC colour space.
%% To do this it checks the ColorConversionStrategy or the device ProcessColorModel if
%% ColorConversionStrategy is not set.
%% This is not 100% reliable. A better solution is for the user to edit this and replace
%% the code between the ---8<--- lines with a simple declaration like:
%%   /N 3
%% where the value of N is the number of components from the profile defined in /ICCProfile above.
%%
[{icc_PDFA}
<<
%% ----------8<--------------8<-------------8<--------------8<----------
  systemdict /ColorConversionStrategy known {
    systemdict /ColorConversionStrategy get cvn dup /Gray eq {
      pop /N 1 false
    }{
      dup /RGB eq {
        pop /N 3 false
      }{
        /CMYK eq {
          /N 4 false
        }{
          (ColorConversionStrategy not a device space, falling back to ProcessColorModel, output may not be valid PDF/A.)=
          true
        } ifelse
      } ifelse
    } ifelse
  } {
    (ColorConversionStrategy not set, falling back to ProcessColorModel, output may not be valid PDF/A.)=
    true
  } ifelse

  {
    currentpagedevice /ProcessColorModel get
    dup /DeviceGray eq {
      pop /N 1
    }{
      dup /DeviceRGB eq {
        pop /N 3
      }{
        dup /DeviceCMYK eq {
          pop /N 4
        } {
          (ProcessColorModel not a device space.)=
          /ProcessColorModel cvx /rangecheck signalerror
        } ifelse
      } ifelse
    } ifelse
  } if
%% ----------8<--------------8<-------------8<--------------8<----------

>> /PUT pdfmark
[{icc_PDFA} ICCProfile (r) file /PUT pdfmark

% Define the output intent dictionary :

[/_objdef {OutputIntent_PDFA} /type /dict /OBJ pdfmark
[{OutputIntent_PDFA} <<
  /Type /OutputIntent               % Must be so (the standard requires).
  /S /GTS_PDFA1                     % Must be so (the standard requires).
  /DestOutputProfile {icc_PDFA}     % Must be so (see above).
  /OutputConditionIdentifier (AdobeRGB1998)      % Customize
>> /PUT pdfmark
[{Catalog} <</OutputIntents [ {OutputIntent_PDFA} ]>> /PUT pdfmark

7. CutePDF also needs some instructions for printing to PDF/A. In the C:\GS_PDFA folder, create an empty text file named PDFWrite.pdfa.rsp. Open the file in Notepad and paste in this text (updated 04/24/2021 for Ghostscript 9.54):

-dPDFA=2
-sColorConversionStrategy=RGB
--permit-file-read="C:/GS_PDFA/AdobeRGB1998.icc"
-sDEVICE=pdfwrite
-dPDFACompatibilityPolicy=1
-dPDFSETTINGS=/default
-dAutoRotatePages=/All
-dNOPAUSE
-dBATCH
-q
"C:\GS_PDFA\PDFA_def.ps"

8. The second part of the instructions for CutePDF must be added to the CutePDF installation folder, C:\Program Files (x86)\Acro Software\CutePDF Writer. You will need Administrator permissions.

Create an empty text file in that folder named setup.ini. Run Notepad as Administrator, open the file, and paste in this text:

[Parameters]
Command="C:\Program Files (x86)\gs\latest\bin\gswin32c.exe"
Arguments=-sOutputFile="%1" @"C:\GS_PDFA\PDFWrite.pdfa.rsp" -

This tells CutePDF where to find your Ghostscript installation and what arguments to pass to it. We are basically telling it to use the commands in our custom PDFWrite.pdfa.rsp, which will in turn load the special PDFA_def.ps file before loading the input stream. And yes, the last line in setup.ini ends in a hyphen (-)!

Print to PDF/A

That’s it! Now, when you print using CutePDF, the file should be created in PDF/A-1b format. After opening in Adobe Reader, you’ll see a blue bar at the top:

Batch Convert PDFA 2

Note that this message does not guarantee compliance with the standard. To test compliance, you can use Adobe Acrobat’s pre-flight testing (Acrobat offers a 30-day free trial). You can also try a free online validator like the one at PDF-Tools.com. I would expect that if one file printed from a certain program passes validation, other files from the same program would also be valid.

Print to Plain PDF

If you want to go back to printing to plain PDF from CutePDF, in the CutePDF installation folder, just rename setup.ini to setup.pdfa.ini. CutePDF will then use its default settings. You can leave the C:\GS_PDFA folder set up so all you need to do for PDF/A printing is to rename setup.pdfa.ini back to setup.ini.

Converting PDF to PDF/A

If you already have a text-based (searchable) PDF file, perhaps received from a bank or utility, you can convert it to PDF/A without printing with CutePDF. See Batch Convert PDF to PDF/A – 2018 Edition.

An Issue with Chrome

At some point, Chrome started rasterizing text in its printed documents, so if you print directly from Chrome 69 to your modified CutePDF, the resulting file will not be searchable, which is half the point of archiving PDFs—to make them searchable. The only workaround I’ve found so far is to change the Destination in Chrome to “Save as PDF”, save the file, then convert it with the batch approach mentioned above.

Batch Convert PDFA 3

Firefox does not have this issue; you can print directly from Firefox to CutePDF to get a PDF/A-2b file.

Leave a Reply

Your email address will not be published. Required fields are marked *

Notify me of followup comments via e-mail. You can also subscribe without commenting.

This site uses Akismet to reduce spam. Learn how your comment data is processed.