2

I am currently trying to generate a PDF that is PDF/A-1(a|b). The platform to which I have to upload the PDF states that all contained images should be compressed using CCITT (group 4) with a resolution less than 310dpi.

I scanned an image in .tif format, used tiffcp -c g4 in order apply CCITT group 4. For the purpose of converting the .tif into an .pdf, I was using tiff2pdf without any options (which should produce an output where all black and white files are compressed into a single strip CCITT G4 Fax).

Afterwards, in order to ensure PDF/A-1(a|b) compatibility, I used the approach described in this post to post-process the .pdf.

When checked with verapdf, the file is PDF/A compliant but it is still rejected from the platform to which I would like to upload the file.

I also tried to copy the black/white image into LibreOffice and exported a PDF/A compliant PDF from there which was rejected, too.

I am just wondering whether I am thinking in the wrong direction; do you know any other (preferably FOSS) tool that could generate a PDF/A compliant .pdf with CCIT compressed images?

Julian
  • 1,694
  • 22
  • 29
  • 1
    I would guess that the monochrome CCITT G4 fax images are being stored in some other compression format, probably (though its a guess since you have supplied neither an example file nor a command line) the 1 BPC DeviceGray image has been converted to a 8 BPC DeviceGray image, and that won't compress well with CCITT G4 fax, so the pdfwrite device has selected Flate. There are numerous controls available to the pdfwrite device, and its possible that you can match the (frankly dumb) requirements of the platform, but I'd need to know a lot more. – KenS Sep 02 '19 at 09:50
  • Thanks @KenS, this clue already helps me a lot. I guess I will play with some of the ghostscript options I found here https://www.volkerschatz.com/tex/hiqpdf.html; the `-dMonoImageFilter=/CCITTFaxEncode` flag looks interesting. If it does not work, I will upload a demo file to better demonstrate the problem. Otherwise, in case it works, I will post a script here. – Julian Sep 02 '19 at 09:59
  • 1
    The pdfwrite (and family) docuemntation is here https://www.ghostscript.com/doc/9.27/VectorDevices.htm#PDFWRITE. Note that the explanation for the 'distiller parameters' is in the Adobe Distiller Parameters documentation, whcih is why we don't document it (our documentation does note that's where to go). The MonoImageFilter won't help you if the image is being converted from 1 Bit Per Component to 8 Bits Per Component, as that's a Gray image, not monochrome. – KenS Sep 02 '19 at 11:02

1 Answers1

1

I solved the problem in the following way.

  1. Saved the image as .png
  2. Encode image using CCITT by running convert img.png -monochrome -compress Group4 -quality 100 img.pdf
  3. Preparing a latex document with the pdfx package to create a PDF/A-1b compliant PDF
  4. Compiling the document using latexmk -lualatex doc.tex
\providecommand{\pdfxopt}{a-1b}
\begin{filecontents*}{\jobname.xmpdata}
\Title{Title}
\Author{Author}
\Subject{Metadata for PDF/X, PDF/A and PDF/E conforming documents}
\Keywords{pdfTeX\sep PDF/X-1a\sep PDF/A-1b\sep PDF/E-1}
\Org{Org}
\CreatorTool{pdfTeX + pdfx.sty with options \pdfxopt}
\Copyright{Copyright}
\CoverDate{2019-09-08}
\setRGBcolorprofile{sRGB_IEC61966-2-1_black_scaled.icc}{sRGB_IEC61966-2-1_black_scaled}{sRGB IEC61966 v2.1 with black scaling}{http://www.color.org}
\FOGRAXXXIX
\end{filecontents*}
\documentclass[11pt,a4paper]{article}
\usepackage{fontspec}
\usepackage[\pdfxopt]{pdfx}
\usepackage{geometry}
\geometry{
a4paper,
total={170mm,257mm},
left=20mm,
top=20mm,
}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[francais]{babel}
\usepackage{sectsty}
\usepackage{graphicx}
\begin{document}
\includegraphics{img.pdf}
\end{document}

You can find the color profiles here.

The resulting document is PDF/A-1b compliant and contains CCITT encoded images

>> pdfimages -list doc.pdf
page   num  type   width height color comp bpc  enc interp  object ID x-ppi y-ppi size ratio
--------------------------------------------------------------------------------------------
   1     0 image     102    83  gray    1   1  ccitt  no        13  0   100   100  116B  11%
Julian
  • 1,694
  • 22
  • 29