From 5fb50679c8e2b55178bac47ce5db253013f3347c Mon Sep 17 00:00:00 2001 From: Evangelos Rigas Date: Mon, 6 Aug 2018 10:57:47 +0100 Subject: [PATCH 2/2] [utils] Add PDF subtype to pdfinfo If the document is compliant with PDF A, E, VT, UA or X standard print GTS version and explain the conformance level. 1 file changed, 104 insertions(+) diff --git a/utils/pdfinfo.cc b/utils/pdfinfo.cc index 4542580b..00fdb6cf 100644 --- a/utils/pdfinfo.cc +++ b/utils/pdfinfo.cc @@ -423,6 +423,108 @@ static void printDestinations(PDFDoc *doc, UnicodeMap *uMap) { } } +static void printPdfSubtype(PDFDoc *doc, UnicodeMap *uMap) { + GooString *part; + GooString *typeExp; + GooString *confExp; + PDFSubtype pdftype; + + Object info = doc->getDocInfo(); + if (info.isDict()) { + pdftype = doc->getPDFSubtype(); + + if (pdftype == subtypeNull | pdftype == subtypeNone) { + return; + } + + switch (pdftype) + { + case subtypePDFA: + printInfoString(info.getDict(), "GTS_PDFA1Version", "GTS version: ", uMap); + typeExp = new GooString("ISO 19005 - Electronic document file format for long-term preservation (PDF/A)"); + break; + case subtypePDFE: + printInfoString(info.getDict(), "GTS_PDFEVersion", "GTS version: ", uMap); + typeExp = new GooString("ISO 24517 - Engineering document format using PDF (PDF/E)"); + break; + case subtypePDFUA: + printInfoString(info.getDict(), "GTS_PDFUAVersion", "GTS version: ", uMap); + typeExp = new GooString("ISO 14289 - Electronic document file format enhancement for accessibility (PDF/UA)");; + break; + case subtypePDFVT: + printInfoString(info.getDict(), "GTS_PDFVTVersion", "GTS version: ", uMap); + typeExp = new GooString("ISO 16612 - Electronic document file format for variable data exchange (PDF/VT)"); + break; + case subtypePDFX: + printInfoString(info.getDict(), "GTS_PDFXVersion", "GTS version: ", uMap); + typeExp = new GooString("ISO 15930 - Electronic document file format for prepress digital data exchange (PDF/X)"); + break; + case subtypeNone: + default: + typeExp = new GooString(""); + break; + } + + switch(doc->getPDFSubtypePart()) + { + case subtypePart1: + part = new GooString("1"); + break; + case subtypePart2: + part = new GooString("2"); + break; + case subtypePart3: + part = new GooString("3"); + break; + case subtypePart4: + part = new GooString("4"); + break; + case subtypePart5: + part = new GooString("5"); + break; + case subtypePartNone: + default: + part = nullptr; + break; + } + + switch (doc->getPDFSubtypeConformance()) + { + case subtypeConfA: + confExp = new GooString("Level A, Accessible"); + break; + case subtypeConfB: + confExp = new GooString("Level B, Basic"); + break; + case subtypeConfG: + confExp = new GooString("Level G, External graphical content");; + break; + case subtypeConfN: + confExp = new GooString("Level N, External ICC profile"); + break; + case subtypeConfP: + confExp = new GooString("Level P, Embedded ICC profile"); + break; + case subtypeConfPG: + confExp = new GooString("Level PG, Embedded ICC profile and external graphical content"); + break; + case subtypeConfU: + confExp = new GooString("Level U, Unicode support"); + break; + case subtypeConfNone: + default: + confExp = nullptr; + break; + } + + printf("PDF subtype: %s\n",typeExp->getCString()); + if (part) + printf("Part: %s\n", part->getCString()); + if (confExp) + printf("Conformance: %s\n", confExp->getCString()); + } +} + static void printInfo(PDFDoc *doc, UnicodeMap *uMap, long long filesize, GBool multiPage) { Page *page; char buf[256]; @@ -595,6 +697,8 @@ static void printInfo(PDFDoc *doc, UnicodeMap *uMap, long long filesize, GBool m // print PDF version printf("PDF version: %d.%d\n", doc->getPDFMajorVersion(), doc->getPDFMinorVersion()); + + printPdfSubtype(doc, uMap); } int main(int argc, char *argv[]) { -- 2.18.0