diff options
author | Ken Sharp <ken.sharp@artifex.com> | 2020-10-01 15:48:19 +0100 |
---|---|---|
committer | Robin Watts <Robin.Watts@artifex.com> | 2020-10-01 16:27:47 +0100 |
commit | 61e227ed7bcdddd652f32f14539702773fcbcf33 (patch) | |
tree | 61be88838b2ecd14ffde9e66e08b501facff151a /devices/gdevpdfocr.c | |
parent | 6290ce42ac84767a84ddc949c9348a194477ab9b (diff) | |
download | ghostpdl-61e227ed7bcdddd652f32f14539702773fcbcf33.tar.gz |
pdfimage devices - fix %Invocation and add /Info dictionary
I'd thought that we had missed off the %Invocation from the PDF output
of the PDF image devices, but in fact it was only that the pdfocr
devices had it emitted in a surprising place in the file.
That's fixed here just by moving when we write it so that its location
is consistent between the devices.
Moved some definitions common to both pdfimage and pdfocr from the
device's .c files to the pdfimage.h file.
Added emission of a very basic /Info dictionary. To facilitate future
enhancements the number of 'static' (ie predefined) objects has been
turned into a #define and we use that wherever possible instead of the
previous hard-coded magic number. Because of the font objects required
for pdfocr, and the fact that they refer to each other, these still
don't use the #define and will have to be manually adjusted if we ever
change this again.
Acrobat ignores the /Info dictionary, apparently it only reads the XML
/Metadata values (at least in modern versions), so adding the Info
dictionary doesn't help. Creating the XMP metadata is unfortunately
quite complicated, we'd need to steal quite a bit of code from pdfwrite
and at the moment I think its more trouble than its worth. I may change
my mind in future.
Diffstat (limited to 'devices/gdevpdfocr.c')
-rw-r--r-- | devices/gdevpdfocr.c | 44 |
1 files changed, 16 insertions, 28 deletions
diff --git a/devices/gdevpdfocr.c b/devices/gdevpdfocr.c index b03116945..dd8fad022 100644 --- a/devices/gdevpdfocr.c +++ b/devices/gdevpdfocr.c @@ -32,24 +32,6 @@ #include "gdevpdfimg.h" -#define COMPRESSION_NONE 1 /* dump mode */ -#define COMPRESSION_LZW 2 /* Lempel-Ziv & Welch */ -#define COMPRESSION_FLATE 3 -#define COMPRESSION_JPEG 4 -#define COMPRESSION_RLE 5 - -static struct compression_string { - unsigned char id; - const char *str; -} compression_strings [] = { - { COMPRESSION_NONE, "None" }, - { COMPRESSION_LZW, "LZW" }, /* Not supported in PCLm */ - { COMPRESSION_FLATE, "Flate" }, - { COMPRESSION_JPEG, "JPEG" }, - { COMPRESSION_RLE, "RLE" }, - { 0, NULL } -}; - int pdf_ocr_open(gx_device *pdev); int pdf_ocr_close(gx_device *pdev); @@ -243,21 +225,27 @@ const gx_device_pdf_image gs_pdfocr32_device = { 0 /* JPEGQ */ }; +/* These strings have object numbers built into them which are only + * correct for a specific value of PDFIMG_STATIC_OBJS (currently 4) + * If we add more static objects (eg Metadata) then we need to update + * the values in the strings below. + */ + /* Funky font */ static const char funky_font[] = -"3 0 obj\n<</BaseFont/GlyphLessFont/DescendantFonts[4 0 R]" -"/Encoding/Identity-H/Subtype/Type0/ToUnicode 6 0 R/Type /Font" +"4 0 obj\n<</BaseFont/GlyphLessFont/DescendantFonts[5 0 R]" +"/Encoding/Identity-H/Subtype/Type0/ToUnicode 7 0 R/Type /Font" ">>\nendobj\n"; static const char funky_font2[] = -"4 0 obj\n<</BaseFont/GlyphLessFont" -"/CIDToGIDMap 5 0 R\n/CIDSystemInfo<<\n" +"5 0 obj\n<</BaseFont/GlyphLessFont" +"/CIDToGIDMap 6 0 R\n/CIDSystemInfo<<\n" "/Ordering (Identity)/Registry (Adobe)/Supplement 0>>" -"/FontDescriptor 7 0 R/Subtype /CIDFontType2/Type/Font" +"/FontDescriptor 8 0 R/Subtype /CIDFontType2/Type/Font" "/DW 500>>\nendobj\n"; static const char funky_font3[] = -"5 0 obj\n<</Length 210/Filter/FlateDecode" +"6 0 obj\n<</Length 210/Filter/FlateDecode" ">>stream\n"; static const char funky_font3a[] = { @@ -294,7 +282,7 @@ static const char funky_font3b[] = "endstream\nendobj\n"; static const char funky_font4[] = -"6 0 obj\n<</Length 353>>\nstream\n" +"7 0 obj\n<</Length 353>>\nstream\n" "/CIDInit /ProcSet findresource begin\n" "12 dict begin\n" "begincmap\n" @@ -320,13 +308,13 @@ static const char funky_font4[] = "endobj\n"; static const char funky_font5[] = -"7 0 obj\n" +"8 0 obj\n" "<</Ascent 1000/CapHeight 1000/Descent -1/Flags 5" -"/FontBBox[0 0 500 1000]/FontFile2 8 0 R/FontName/GlyphLessFont" +"/FontBBox[0 0 500 1000]/FontFile2 9 0 R/FontName/GlyphLessFont" "/ItalicAngle 0/StemV 80/Type/FontDescriptor>>\nendobj\n"; static const char funky_font6[] = -"8 0 obj\n<</Length 572/Length1 572>>\nstream\n"; +"9 0 obj\n<</Length 572/Length1 572>>\nstream\n"; static const char funky_font6a[] = { |