head 1.4; access; symbols pkgsrc-2019Q3:1.3.0.2 pkgsrc-2019Q3-base:1.3 pkgsrc-2017Q3:1.1.0.4 pkgsrc-2017Q3-base:1.1; locks; strict; comment @// @; 1.4 date 2019.10.20.12.17.19; author leot; state dead; branches; next 1.3; commitid X0FfH7Davhu3qBHB; 1.3 date 2019.09.20.11.11.52; author prlw1; state Exp; branches; next 1.2; commitid AYMZZNCgGNme1KDB; 1.2 date 2017.10.23.13.07.56; author leot; state dead; branches; next 1.1; commitid CfQxNKWoCZpb4bcA; 1.1 date 2017.09.07.11.24.29; author prlw1; state Exp; branches; next ; commitid GdDvMx6nvvOlYf6A; desc @@ 1.4 log @cups-filters: Update to 1.25.11 pkgsrc changes: - Remove patch-filter_pdf.cxx (was a backport from upstream) and patch-Makefile.in (now `-r' option of `ln' is checked in configure phase) Changes: 1.25.11 ------- - cups-browsed: Really accept entries without printer name reported on a job status request (Issue #163). - cups-browsed: Strip IPP atrribute values reported by the printer on a get-printer-attributes request from white space (Pull request #166). 1.25.10 ------- - libcupsfilters: Added NULL checks when handling page size names as some of the page sizes in CUPS' PWG media list have a NULL PPD name (Ubuntu bug #1847488). 1.25.9 ------ - cups-browsed: Fix leaks in get_printer_attributes() function. - cups-browsed: Avoid infinite recursion on IPP 1.1 fallback. 1.25.8 ------ - cups-browsed: On a job status request accept also entries without the printer name being reported (Issue #163). - cups-browsed: Fall back to IPP 1.1 if a get-printer-attributes IPP request with IPP 2.x fails (Issue #124, Issue #163). - gstoraster: Use ".setfilladjust2" instead of the undocumented ".setfilladjust" PostScript command for Center-of-Pixel method to fill paths (Issue #164). 1.25.7 ------ - implicitclass, libcupsfilters: Fixes to solve an assertion error and printing to an Apple Raster printer (Issue #162, Ubuntu bug #1845286, Ubuntu bug #1845548). - cups-browsed: Do not try to resolve the network interface name on Avahi messages which are not interface-related (like "All for now"or "Cache exhausted", Issue #163). - Build system: The helper script ln-srf to build on systems with old ln was not included in the release tarballs (Issue #161). - pdftoraster: Fixed some bugs in output bitmap generation ( writePageImage() function): Segfault on output of up-side-down pages (back side when printing duplex on some printers), margin offsets not taken into account on monochrome jobs, CUPS_CSPACE_W color space not recognized as monochrome (Ubuntu bug #1845286). 1.25.6 ------ - implicitclass: Make sure the destination printer gets always set and do not pass on the cups-browsed-dest-printer when sending the job to the final destination (Issue #152, Pull request #159). - Build system: Support old ln versions without the -r option (Pull request #154, #157). - texttotext: Link with libiconv if needed (Pull request #155, #158). - foomatic-rip: Fix argument representation for raw queue debug mesaage (Pull request #153). 1.25.5 ------ - bannertopdf: Added missing "#include " to pdf.cxx so that bannertopdf correctly builds with QPDF 9.0.0 (Issue #134, Issue #151, Gentoo bug #693498). - rastertopdf: Let the getIPPColorProfileName() function not return a pointer to a local variable (clang warning, Issue #150). - cups-browsed: If a locally generated queue (usually with "implicitclass://..." URI) left over from a previous (crashed) session is picked up on startup, do not set the URI as the remote printer's URI and do not cause a fatal error on a failed get-printer-attributes IPP request (Issue #148, Debian bug #939316). - pdftopdf: Do not preserve encryption, since the output already goes into the printer (Issue #146, Pull request #147). 1.25.4 ------ - imagetoraster: Do not call imagetops and pstoraster for classifications and page labels as these filters are not included any more with cups-filters. Classifications and page labels are currently not supported for direct image printing, only for PDF or PostScript input (which goes through pdftopdf). - imagetoraster, imagetopdf: Fixed auto-rotation of images to fit output page best (Issue #145). - pdftoraster: If the PPD contains several equally-sized page size entries which match the size of the input page and one is the size selected by the user via the "PageSize" or "media" option (or the default selection in the PPD) then prefer this one instead of simply the first matching one. - pdftoraster: If the input page size cannot be matched with one of the PPD's page sizes it is considered a custom size, fill the page size name field of the CUPS Raster header with "Custom.XXXxYYY" then. - pdftoraster: Match the input page size with a page size in the PPD only if the differences of the dimensions are less than 1%, also match the input page size against the imageable area of the PPD's page sizes if no match with the full page size is found (Issue #138). 1.25.3 ------ - Sample PPDs: In HP-Color_LaserJet_CM3530_MFP-PDF.ppd renamed "custom" choice of the option "stapleoption" to "customsize" as from CUPS 2.2.12 on "custom" is not accepted any more as a choice name in a PPD file. - cups-browsed: Fixed check whether the remote printer understands PWG Raster (Issue #141). 1.25.2 ------ - foomatic-rip: Fixed segmentation fault when running foomatic-rip by hand and the PRINTER environment variable is not set (Pull request #139). - cups-browsed: Added note to cups-browsed.conf and man page about IP-based URIs depending on the network interface used. - cups-browsed: For each DNS-SD-discovered printer register each DNS-SD discovery instance with network interface, family, and IPP type. When DNS-SD messages of instances disappearing show up, only unregister this instance and remove the printer only if no instance is left. This prevents a local queue of a still available printer being removed when Wi-Fi (= one interface) is turned off (Issue #136). - cups-browsed: If a remote printer is served from the local machine, prefer the "localhost"/loopback interface URI. - cups-browsed: If a remote printer is discovered more than once, use the new instance only if it has no downgrades and at least one upgrade compared to the old one. Features currently compared are IPP/IPPS, loopback interface or not, and discovery via CUPS legacy/LDAP/DNS-SD. - cups-browsed: If an Avahi-discovered entry comes through the "lo" interface, always use the host name "localhost". Use IP addresses instead of host names only if explicitly requested. - cups-browsed: Consider remote printer entries also as from the same printer if one has the local machine's network name and the other "localhost" as host name (Issue #136). 1.25.1 ------ - imagetopdf: Fixed crash when no PPD file was supplied (Pull request #133). - pdftoraster: Fixed offset issues leading to segmentation faults (Issue #131, Pull request #132). - pdftoraster: Added anti-aliasing for better raster image quality (Pull request #129). - pdftoraster: Added graceful handling of zero-page input (Issue #117, Pull request #127). 1.25.0 ------ - pdftoijs, pdftoopvp: Removed these deprecated filters completely as there is no demand for them any more. They also used unstable, undocumented APIs of Poppler. - pdftoraster: Changed from using unstable, undocumented APIs of Poppler to stable, documented ones, to improve maintainability of this filter, and with it of the cups-filters package. Thanks to Tanmay Anand for contributing this as his Google Summer of Code 2019 project. - libcupsfilters: Added support for color spaces CMY and RGBW when using filters without PPD file (mainly for development and debugging, option "print-color-mode" with values "cmy-XX" and "rgbw-XX" with XX being the number of bits per color). 1.24.0 ------ - cups-browsed: Integration of Deepak Patankar's Google Summer of Code 2018 project with the main goal of clustering different printers and automatically selecting the destination printers by job content and option/attribute settings. All changes of this release are done by Deepak as parts of his project. - cups-browsed, implicitclass: Support for mixed clusters of remote CUPS queues and IPP network printers. For this PPD files of remote CUPS queues are generated by cups-browsed based on IPP queries, as for native IPP printers, the number of jobs for load balancing is polled in a way that it works also with native IPP printers, the implicitclass backend sends jobs directky to the printer instead of re-queueing them via CUPS. - cups-browsed: Merge IPP attributes of several printers to combined attributes for the cluster to generate the cluster's PPD file, including PPD constraints for option combinations not fulfillable by any of the member printers, and finding reasonable, non-conflicting default settings, - cups-browsed: Selection algorithm for the destination printer for a job sent to the cluster. Based on the job settings requested such as page size, media type, print quality, ... the best most suitable printer in the cluster for the job will be selected. - cups-browsed, implicitclass: Filter jobs to clusters already locally. Due to the fact that a cluster's member printers are not exclusively non-raw CUPS queues with the complete filtering framework on the remote server, but also native IPP printers, we need to support generic driverless printers as destination. So we cannot pass on the input data unfiltered but need to filter locally. We let the cluster's PPD file emulate a PDF printer, letting the local CUPS queue of the cluster run pdftopdf and any pre-filters to turn the input into PDF and we let the implicitclass backend turn PDF into a format understood by the destination printer, supporting the 4 formats of driverless IPP printing: PDF, PWG Raster, Apple Raster, PCLm. @ text @$NetBSD: patch-filter_pdf.cxx,v 1.3 2019/09/20 11:11:52 prlw1 Exp $ Fix build with qpdf 9.0 https://github.com/OpenPrinting/cups-filters/commit/1878ecd2ef533c3dbe6e6bc29018ce4bf8246e83 --- filter/pdf.cxx.orig 2019-05-16 13:02:29.000000000 +0000 +++ filter/pdf.cxx @@@@ -20,6 +20,7 @@@@ #include "pdf.h" #include #include +#include #include #include #include @ 1.3 log @Fix build of cups-filters with qpdf 9.0 @ text @d1 1 a1 1 $NetBSD$ @ 1.2 log @cups-filters: Update print/cups-filters to 1.17.9 pkgsrc changes: - Delete patches/patch-filter_pdf.cxx that add support to poppler-0.58, applied upstream Changes: 1.17.9 ------ - cups-browsed: Applying option defaults from the DefaultOptions directive in cups-browsed.conf got lost. Re-introduced it (Bug #1414). - cups-browsed: Get printer-location field from remote printers. Thanks to Marek Kasik for the patch (Bug #1413). 1.17.8 ------ - foomatic-rip: Change execution of renderer thread to fail whenever any of its individual sub-comands fails. Thanks to LUUM (luum at chromium dot org) for the patch (Bug #1412). - foomatic-rip: Parent process now ignores SIGPIPE calls from upstream/downstream CUPS filters, per https://www.cups.org/doc/api-filter.html, while correctly noting child process failures and exiting accordingly. Thanks to LUUM (luum at chromium dot org) for the patch (Bug #1412). - Build system: Fixed typo which broke the "--enable-gs-ps2write" ./configure command line option (Bug #1410). 1.17.7 ------ - braille: Add a mirror option for graphical output. Thanks to Samuel Thibault for this patch. - braille: Rename the internal cups name of the Resize option to the standard well-known and well-documented fitplot option. Thanks to Samuel Thibault for this patch. - braille: Add support for margins in graphical mode, defaulting them to 15 points (a bit more than 5mm). Thanks to Samuel Thibault for this patch. - braille: Updated French translation. Thanks to Samuel Thibault for this patch. - braille: Add a PPD which generates UBRL output, i.e. Braille expressed in Unicode. This is not useful for actual embossers, but very convenient to check output to be embossed without wasting paper. Thanks to Samuel Thibault for this patch. - braille: Add virtual BRF backend for generating ready-to-emboss BRF files with CUPS, similarly to the cups-pdf backend. Thanks to Samuel Thibault for this patch. - braille: Some tools seem to emit true/false instead of True/False, so let us cope with it. Thanks to Samuel Thibault for this patch. - braille: "make uninstall" did not remove all the links. Thanks to Samuel Thibault for this patch. - braille: Add support for embossing MusicXML files, through the FreeDots transcriptor. Thanks to Samuel Thibault for this patch. - braille: Add proper support for hardware margins on braille embossers. Thanks to Samuel Thibault for this patch. - braille: Fix the disabling of the text margins in Index graphics mode. Thanks to Samuel Thibault for this patch. - braille: Support for direct, structured embossing of XML and XML-based file formats (like odt, docx, ...). Thanks to Samuel Thibault for this patch. 1.17.6 ------ - braille: Embossers can only emboss integer numbers of 2x4 cells. Thanks to Samuel Thibault for this patch. - braille: In Index graphical mode we need to disable the text margins, since they come in earlier on the way to there. Thanks to Samuel Thibault for this patch. - braille: Also, we should always add a 1.6mm margin for taking into account the width of dots. Thanks to Samuel Thibault for this patch. 1.17.5 ------ - libcupsfilters: In the PPD generator for driverless printing renamed the "print-quality" option back to "cupsPrintQuality" as the support for this option got fixed in CUPS (CUPS issue #5090). - braille: Improvements on the braille support for bitmap images: Moves the graphical dot distance option to the image conversion group, add an option to avoid image resize, and make the rotation option easier by proposing to just fit paper instead of fitting portrait or landscape. Thanks to Samuel Thibault for this patch. - braille: Support for embossing vector images as braille. Thanks to Samuel Thibault for this patch. - braille: Fix liblouis1.defs installation. Thanks to Samuel Thibault for this fix. 1.17.4 ------ - pdftopdf: If the input PDF file contains an interactive form, flatten it to static PDF so that further manipulation, like scaling, number-up, ... do not let the filled for content getting lost. This is implemented by using the pdftocairo utility of Poppler and if this fails Ghostscript (9.22 or later recommended). This will probably replaced by a QPDF-based solution later. Thanks to Tobias Hoffmann for the QPDF-based detection of PDF forms (Bug #1315, Ubuntu bug #1564249). 1.17.3 ------ - bannertopdf: Make it working also with Poppler 0.58.0 and newer (Bug #1408). - gstoraster, pdftops, foomatic-rip: Added "-dShowAcroForm" to all Ghostscript command lines where the input data format can be PDF. With this and the fix of Ghostscript bug #698461 most filled PDF forms should be rendered correctly by Ghostscript now. - libcupsfilters: Do not check maximum resolutions of raster-based PDLs, as implementation was incorrect and reliability of PDLs is more important than maximum resolution. @ text @d1 1 a1 1 $NetBSD: patch-filter_pdf.cxx,v 1.1 2017/09/07 11:24:29 prlw1 Exp $ d3 2 a4 2 support poppler-0.58 https://bugs.linuxfoundation.org/show_bug.cgi?id=1408 d6 1 a6 1 --- filter/pdf.cxx.orig 2017-08-15 18:29:57.000000000 +0000 d8 8 a15 817 @@@@ -129,64 +129,125 @@@@ extern "C" void pdf_prepend_stream(pdf_t Object array; Ref r; +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + pageobj = xref->fetch(pageref->num, pageref->gen); +#else xref->fetch(pageref->num, pageref->gen, &pageobj); - if (!pageobj.isDict() || !pageobj.dictLookupNF("Contents", &contents)) { +#endif + if (!pageobj.isDict() || +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + (contents = pageobj.dictLookupNF("Contents")).isNull() +#else + !pageobj.dictLookupNF("Contents", &contents) +#endif + ) { fprintf(stderr, "Error: malformed pdf\n"); return; } - if (contents.isRef()) + if (contents.isRef()) { +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + contents = xref->fetch(contents.getRefNum(), contents.getRefGen()); +#else xref->fetch(contents.getRefNum(), contents.getRefGen(), &contents); +#endif + } +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + (void) lenobj; + dict = Object(new Dict(xref)); + dict.dictSet("Length", Object(static_cast(len))); + stream = Object(static_cast(new MemStream(buf, 0, len, std::move(dict)))); +#else lenobj.initInt(len); dict.initDict(xref); dict.dictSet("Length", &lenobj); stream.initStream(new MemStream(buf, 0, len, &dict)); +#endif r = xref->addIndirectObject(&stream); +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + streamrefobj = Object(r.num, r.gen); +#else streamrefobj.initRef(r.num, r.gen); +#endif +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + array = Object(new Array(xref)); + array.arrayAdd(std::move(streamrefobj)); +#else array.initArray(xref); array.arrayAdd(&streamrefobj); +#endif if (contents.isStream()) { +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + contents = pageobj.dictLookupNF("Contents"); // streams must be indirect, i.e. not fetch()-ed + array.arrayAdd(std::move(contents)); +#else pageobj.dictLookupNF("Contents", &contents); // streams must be indirect, i.e. not fetch()-ed array.arrayAdd(&contents); +#endif } else if (contents.isArray()) { int i, len = contents.arrayGetLength(); Object obj; for (i = 0; i < len; i++) { +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + obj = contents.arrayGetNF(i); + array.arrayAdd(std::move(obj)); +#else contents.arrayGetNF(i, &obj); array.arrayAdd(&obj); +#endif } } else fprintf(stderr, "Error: malformed pdf\n"); +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + pageobj.dictSet("Contents", std::move(array)); +#else pageobj.dictSet("Contents", &array); +#endif xref->setModifiedObject(&pageobj, *pageref); +#if POPPLER_VERSION_MAJOR <= 0 && POPPLER_VERSION_MINOR < 58 pageobj.free(); +#endif } +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 +static Object name_object(const char *s) +{ + return Object(new GooString(s)); +} +#else static Object * name_object(const char *s) { Object *o = new Object(); o->initName((char *)s); return o; } +#endif /* * Create new PDF integer type object. */ +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 +static Object int_object(int i) +{ + return Object(i); +} +#else static Object * int_object(int i) { Object *o = new Object(); o->initInt(i); return o; } +#endif static Object * get_resource_dict(XRef *xref, Dict *pagedict, @@@@ -196,21 +257,36 @@@@ static Object * get_resource_dict(XRef * Object res; /* TODO resource dict can also be inherited */ +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + res = pagedict->lookupNF("Resources"); + if (res.isNull()) +#else if (!pagedict->lookupNF("Resources", &res)) +#endif return NULL; if (res.isRef()) { *resref = res.getRef(); +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + *resdict = xref->fetch(resref->num, resref->gen); +#else xref->fetch(resref->num, resref->gen, resdict); +#endif } else if (res.isDict()) { +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + *resdict = res.copy(); +#else res.copy(resdict); +#endif resref->num = 0; } else resdict = NULL; +#if POPPLER_VERSION_MAJOR <= 0 && POPPLER_VERSION_MINOR < 58 res.free(); +#endif return resdict; } @@@@ -226,7 +302,11 @@@@ extern "C" void pdf_add_type1_font(pdf_t Object resdict; Ref resref; +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + pageobj = xref->fetch(pageref->num, pageref->gen); +#else xref->fetch(pageref->num, pageref->gen, &pageobj); +#endif if (!pageobj.isDict()) { fprintf(stderr, "Error: malformed pdf\n"); return; @@@@ -234,21 +314,35 @@@@ extern "C" void pdf_add_type1_font(pdf_t if (!get_resource_dict(xref, pageobj.getDict(), &resdict, &resref)) { fprintf(stderr, "Error: malformed pdf\n"); +#if POPPLER_VERSION_MAJOR <= 0 && POPPLER_VERSION_MINOR < 58 pageobj.free(); +#endif return; } +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + font = Object(new Dict(xref)); +#else font.initDict(xref); +#endif font.dictSet("Type", name_object("Font")); font.dictSet("Subtype", name_object("Type1")); font.dictSet("BaseFont", name_object(name)); xref->addIndirectObject(&font); +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + fonts = resdict.dictLookupNF("Font"); +#else resdict.dictLookupNF("Font", &fonts); +#endif if (fonts.isNull()) { /* Create new font dic obj in page's resources */ +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + resdict.dictSet("Font", Object(new Dict(xref))); +#else fonts.initDict(xref); resdict.dictSet("Font", &fonts); +#endif } Object *fonts_dic; @@@@ -259,7 +353,11 @@@@ extern "C" void pdf_add_type1_font(pdf_t fonts_dic = &fonts; } else if ( fonts.isRef() ) { /* "Font" resource is indirect reference object */ +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + dereferenced_obj = xref->fetch(fonts.getRefNum(), fonts.getRefGen()); +#else xref->fetch(fonts.getRefNum(), fonts.getRefGen(), &dereferenced_obj); +#endif fonts_dic = &dereferenced_obj; } @@@@ -269,7 +367,11 @@@@ extern "C" void pdf_add_type1_font(pdf_t } /* Add new entry to "Font" resource */ +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + fonts_dic->dictSet("bannertopdf-font", std::move(font)); +#else fonts_dic->dictSet("bannertopdf-font", &font); +#endif /* Notify poppler about changes */ if ( fonts.isRef() ) { @@@@ -281,7 +383,9 @@@@ extern "C" void pdf_add_type1_font(pdf_t else xref->setModifiedObject(&resdict, resref); +#if POPPLER_VERSION_MAJOR <= 0 && POPPLER_VERSION_MINOR < 58 pageobj.free(); +#endif } @@@@ -293,23 +397,38 @@@@ static bool dict_lookup_rect(Object *dic Array *array; int i; +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + o = dict->dictLookup(key); + if (o.isNull()) +#else if (!dict->dictLookup(key, &o)) +#endif return false; if (!o.isArray()) { +#if POPPLER_VERSION_MAJOR <= 0 && POPPLER_VERSION_MINOR < 58 o.free(); +#endif return false; } array = o.getArray(); for (i = 0; i < 4; i++) { Object el; +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + el = array->get(i); + if (el.isNum()) + rect[i] = el.getNum(); +#else if (array->get(i, &el) && el.isNum()) rect[i] = el.getNum(); el.free(); +#endif } +#if POPPLER_VERSION_MAJOR <= 0 && POPPLER_VERSION_MINOR < 58 o.free(); +#endif return i == 4; } @@@@ -322,6 +441,15 @@@@ static void dict_set_rect(XRef *xref, Object array; int i; +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + array = Object(new Array(xref)); + + for (i = 0; i < 4; i++) { + array.arrayAdd(Object(static_cast(rect[i]))); + } + + dict->dictSet(key, std::move(array)); +#else array.initArray(xref); for (i = 0; i < 4; i++) { @@@@ -331,6 +459,7 @@@@ static void dict_set_rect(XRef *xref, } dict->dictSet(key, &array); +#endif } @@@@ -361,7 +490,11 @@@@ extern "C" void pdf_resize_page (pdf_t * float mediabox[4] = { 0.0, 0.0, width, length }; float old_mediabox[4]; +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + pageobj = xref->fetch(pageref->num, pageref->gen); +#else xref->fetch(pageref->num, pageref->gen, &pageobj); +#endif if (!pageobj.isDict()) { fprintf(stderr, "Error: malformed pdf\n"); return; @@@@ -381,7 +514,9 @@@@ extern "C" void pdf_resize_page (pdf_t * dict_set_rect (xref, &pageobj, "BleedBox", mediabox); xref->setModifiedObject(&pageobj, *pageref); +#if POPPLER_VERSION_MAJOR <= 0 && POPPLER_VERSION_MINOR < 58 pageobj.free(); +#endif } @@@@ -394,21 +529,34 @@@@ extern "C" void pdf_duplicate_page (pdf_ Object page, parentref, parent, kids, ref, countobj; int i; +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + page = xref->fetch(pageref->num, pageref->gen); +#else xref->fetch(pageref->num, pageref->gen, &page); +#endif if (!page.isDict("Page")) { fprintf(stderr, "Error: malformed pdf (invalid Page object)\n"); return; } +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + parentref = page.dictLookupNF("Parent"); + parent = parentref.fetch(xref); +#else page.dictLookupNF("Parent", &parentref); parentref.fetch(xref, &parent); +#endif if (!parent.isDict("Pages")) { fprintf(stderr, "Error: malformed pdf (Page.Parent must point to a " "Pages object)\n"); return; } +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + kids = parent.dictLookup("Kids"); +#else parent.dictLookup("Kids", &kids); +#endif if (!kids.isArray()) { fprintf(stderr, "Error: malformed pdf (Pages.Kids must be an array)\n"); return; @@@@ -420,14 +568,22 @@@@ extern "C" void pdf_duplicate_page (pdf_ // the pages tree (not supported by major pdf implementations). for (i = 1; i < count; i++) { Ref r = xref->addIndirectObject(&page); +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + kids.arrayAdd(Object(r.num, r.gen)); +#else ref.initRef(r.num, r.gen); kids.arrayAdd(&ref); ref.free(); +#endif } +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + parent.dictSet("Count", Object(count)); +#else countobj.initInt(count); parent.dictSet("Count", &countobj); countobj.free(); +#endif xref->setModifiedObject(&parent, parentref.getRef()); } @@@@ -523,7 +679,11 @@@@ extern "C" int pdf_fill_form(pdf_t *doc, } Object pageobj; Ref pageref = page->getRef(); +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + pageobj = xref->fetch(pageref.num, pageref.gen); +#else xref->fetch(pageref.num, pageref.gen, &pageobj); +#endif const char *font_size = lookup_opt(opt, "banner-font-size"); if ( ! font_size ) { @@@@ -614,8 +774,12 @@@@ extern "C" int pdf_fill_form(pdf_t *doc, /* Modify field's appearance */ Object appearance_obj; +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + field_obj->getDict()->set("DA", Object(appearance)); +#else appearance_obj.initString(appearance); field_obj->getDict()->set("DA", &appearance_obj); +#endif /* * Create /AP - entry stuff. @@@@ -653,7 +817,11 @@@@ extern "C" int pdf_fill_form(pdf_t *doc, appearance_stream->append("EMC\n"); Object appearance_stream_dic; +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + appearance_stream_dic = Object(new Dict(xref)); +#else appearance_stream_dic.initDict(xref); +#endif /* * Appearance stream dic. @@@@ -663,12 +831,46 @@@@ extern "C" int pdf_fill_form(pdf_t *doc, appearance_stream_dic.dictSet("Type", name_object("XObject")); appearance_stream_dic.dictSet("Subtype", name_object("Form")); appearance_stream_dic.dictSet("FormType", int_object(1)); +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + appearance_stream_dic.dictSet("Resources", Object(resref.num, resref.gen)); +#else Object obj_ref_x; obj_ref_x.initRef(resref.num, resref.gen); appearance_stream_dic.dictSet("Resources", &obj_ref_x); +#endif /* BBox array: TODO. currently out of the head. */ Object array; +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + array = Object(new Array(xref)); + array.arrayAdd(Object(0.0)); + array.arrayAdd(Object(0.0)); + array.arrayAdd(Object(237.0)); + array.arrayAdd(Object(25.0)); + + appearance_stream_dic.dictSet("BBox", std::move(array)); + appearance_stream_dic.dictSet("Length", Object(appearance_stream->getLength())); + + MemStream *mem_stream = new MemStream(appearance_stream->getCString(), + 0, appearance_stream->getLength(), std::move(appearance_stream_dic)); + + /* Make obj stream */ + Object stream = Object(static_cast(mem_stream)); + + Ref r = xref->addIndirectObject(&stream); + + /* Update Xref table */ + Object obj_ref = Object(r.num, r.gen); + + /* + * Fill Annotation's appearance streams dic /AP + * See: 8.4.4 Appearance Streams + */ + Object appearance_streams_dic = Object(new Dict(xref)); + appearance_streams_dic.dictSet("N", std::move(obj_ref)); + + field_obj->getDict()->set("AP", std::move(appearance_streams_dic)); +#else array.initArray(xref); Object el; el.initReal(0); @@@@ -705,6 +907,7 @@@@ extern "C" int pdf_fill_form(pdf_t *doc, appearance_streams_dic.dictSet("N", &obj_ref); field_obj->getDict()->set("AP", &appearance_streams_dic); +#endif /* Notify poppler about changes */ xref->setModifiedObject(field_obj, field_ref); @@@@ -721,24 +924,38 @@@@ extern "C" int pdf_fill_form(pdf_t *doc, * OpenOffice - by default sets it to 'true'. */ Object *obj_form = catalog->getAcroForm(); +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + obj_form->dictSet("NeedAppearances", Object(gFalse)); +#else Object obj1; obj1.initBool(gFalse); obj_form->dictSet("NeedAppearances", &obj1); +#endif + /* Add AccroForm as indirect obj */ Ref ref_form = xref->addIndirectObject(obj_form); /* * So update Catalog object. */ +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + Object catObj = xref->getCatalog(); +#else Object* catObj = new Object(); catObj = xref->getCatalog(catObj); +#endif Ref catRef; catRef.gen = xref->getRootGen(); catRef.num = xref->getRootNum(); +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + catObj.dictSet("AcroForm", Object(ref_form.num, ref_form.gen)); + xref->setModifiedObject(&catObj, catRef); +#else Object obj2; obj2.initRef(ref_form.num, ref_form.gen); catObj->dictSet("AcroForm", &obj2); xref->setModifiedObject(catObj, catRef); +#endif /* Success */ return 1; @@@@ -780,7 +997,11 @@@@ static int pdf_embed_font(pdf_t *doc, /* Font dictionary object for embeded font */ Object f_dic; +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + f_dic = Object(new Dict(xref)); +#else f_dic.initDict(xref); +#endif f_dic.dictSet("Type", name_object("Font")); /* Stream lenght */ @@@@ -798,12 +1019,18 @@@@ static int pdf_embed_font(pdf_t *doc, } /* Create memory stream font. Add it to font dic. */ +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + MemStream *mem_stream = new MemStream(font_stream->getCString(), + 0, outlen, std::move(f_dic)); + Object stream = Object(static_cast(mem_stream)); +#else MemStream *mem_stream = new MemStream(font_stream->getCString(), 0, outlen, &f_dic); /* Make obj stream */ Object stream; stream.initStream(mem_stream); +#endif Ref r; @@@@ -813,7 +1040,11 @@@@ static int pdf_embed_font(pdf_t *doc, /* Get page object */ Object pageobj; Ref pageref = page->getRef(); +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + pageobj = xref->fetch(pageref.num, pageref.gen); +#else xref->fetch(pageref.num, pageref.gen, &pageobj); +#endif if (!pageobj.isDict()) { fprintf(stderr, "Error: malformed pdf.\n"); return 0; @@@@ -825,18 +1056,29 @@@@ static int pdf_embed_font(pdf_t *doc, Object *ret = get_resource_dict(xref, pageobj.getDict(), &resdict, &resref); if ( !ret ) { fprintf(stderr, "Error: malformed pdf\n"); +#if POPPLER_VERSION_MAJOR <= 0 && POPPLER_VERSION_MINOR < 58 pageobj.free(); +#endif return 0; } /* Dictionary for all fonts in page's resources */ Object fonts; +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + fonts = resdict.dictLookupNF("Font"); +#else resdict.dictLookupNF("Font", &fonts); +#endif if (fonts.isNull()) { /* Create new one, if doesn't exists */ +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + resdict.dictSet("Font", Object(new Dict(xref))); + fonts = resdict.dictLookupNF("Font"); +#else fonts.initDict(xref); resdict.dictSet("Font", &fonts); +#endif fprintf(stderr, "Create new font dict in page's resources.\n"); } @@@@ -866,7 +1108,11 @@@@ static int pdf_embed_font(pdf_t *doc, /* r - cid resource dic */ Object font_res_obj_ref; +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + font_res_obj_ref = Object(r.num, r.gen); +#else font_res_obj_ref.initRef(r.num, r.gen); +#endif Object *fonts_dic; Object dereferenced_obj; @@@@ -876,7 +1122,11 @@@@ static int pdf_embed_font(pdf_t *doc, fonts_dic = &fonts; } else if ( fonts.isRef() ) { /* "Font" resource is indirect reference object */ +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + dereferenced_obj = xref->fetch(fonts.getRefNum(), fonts.getRefGen()); +#else xref->fetch(fonts.getRefNum(), fonts.getRefGen(), &dereferenced_obj); +#endif fonts_dic = &dereferenced_obj; } @@@@ -886,7 +1136,11 @@@@ static int pdf_embed_font(pdf_t *doc, } /* Add to fonts dic new font */ +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + fonts_dic->dictSet("stanv_font", std::move(font_res_obj_ref)); +#else fonts_dic->dictSet("stanv_font", &font_res_obj_ref); +#endif /* Notify poppler about changes in fonts dic */ if ( fonts.isRef() ) { @@@@ -897,7 +1151,9 @@@@ static int pdf_embed_font(pdf_t *doc, xref->setModifiedObject(&resdict, resref); fprintf(stderr, "Resource dict was changed.\n"); +#if POPPLER_VERSION_MAJOR <= 0 && POPPLER_VERSION_MINOR < 58 pageobj.free(); +#endif /* Success */ return 1; @@@@ -1104,8 +1360,12 @@@@ static Object *make_fontdescriptor_dic( XRef *xref = doc->getXRef(); /* Font dictionary for embeded font */ +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + Object *dic = new Object(new Dict(xref)); +#else Object *dic = new Object(); dic->initDict(xref); +#endif dic->dictSet("Type", name_object("FontDescriptor")); dic->dictSet( @@@@ -1119,6 +1379,15 @@@@ static Object *make_fontdescriptor_dic( dic->dictSet("StemV", int_object(fdes->stemV)); /* FontBox array */ +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + Object array = Object(new Array(xref)); + array.arrayAdd(Object(static_cast(fdes->bbxmin))); + array.arrayAdd(Object(static_cast(fdes->bbymin))); + array.arrayAdd(Object(static_cast(fdes->bbxmax))); + array.arrayAdd(Object(static_cast(fdes->bbymax))); + + dic->dictSet("FontBBox", std::move(array)); +#else Object array; array.initArray(xref); @@@@ -1137,6 +1406,7 @@@@ static Object *make_fontdescriptor_dic( array.arrayAdd(&el); dic->dictSet("FontBBox", &array); +#endif if (fdes->xHeight) { dic->dictSet("XHeight", int_object(fdes->xHeight)); @@@@ -1149,20 +1419,34 @@@@ static Object *make_fontdescriptor_dic( if (fdes->panose) { /* Font dictionary for embeded font */ Object style_dic; +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + style_dic = Object(new Dict(xref)); +#else style_dic.initDict(xref); +#endif + + GooString *panose_str = new GooString(fdes->panose, 12); +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + style_dic.dictSet("Panose", Object(panose_str)); + dic->dictSet("Style", std::move(style_dic)); +#else Object panose; - GooString *panose_str = new GooString(fdes->panose, 12); panose.initString(panose_str); style_dic.dictSet("Panose", &panose); dic->dictSet("Style", &style_dic); +#endif } +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + dic->dictSet(emb_pdf_get_fontfile_key(emb), Object(fontfile_obj_ref.num, fontfile_obj_ref.gen)); +#else Object ref_obj; ref_obj.initRef(fontfile_obj_ref.num, fontfile_obj_ref.gen); dic->dictSet(emb_pdf_get_fontfile_key(emb), &ref_obj); +#endif return dic; } @@@@ -1181,8 +1465,12 @@@@ static Object *make_font_dic( /* Get XREF table */ XRef *xref = doc->getXRef(); +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + Object *dic = new Object(new Dict(xref)); +#else Object *dic = new Object(); dic->initDict(xref); +#endif dic->dictSet("Type", name_object("Font")); dic->dictSet( @@@@ -1192,15 +1480,23 @@@@ static Object *make_font_dic( "BaseFont", name_object(copyString(emb_pdf_escape_name(fdes->fontname,-1)))); +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + dic->dictSet("FontDescriptor", Object(fontdescriptor_obj_ref.num, fontdescriptor_obj_ref.gen)); +#else Object ref_obj; ref_obj.initRef(fontdescriptor_obj_ref.num, fontdescriptor_obj_ref.gen); dic->dictSet("FontDescriptor", &ref_obj); +#endif if ( emb->plan & EMB_A_MULTIBYTE ) { assert(fwid->warray); Object CIDSystemInfo_dic; +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + CIDSystemInfo_dic = Object(new Dict(xref)); +#else CIDSystemInfo_dic.initDict(xref); +#endif Object registry; Object ordering; @@@@ -1208,16 +1504,28 @@@@ static Object *make_font_dic( GooString *str; str = new GooString(copyString(fdes->registry)); +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + CIDSystemInfo_dic.dictSet("Registry", Object(str)); +#else registry.initString(str); CIDSystemInfo_dic.dictSet("Registry", ®istry); +#endif str = new GooString(copyString(fdes->ordering)); +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + CIDSystemInfo_dic.dictSet("Ordering", Object(str)); +#else ordering.initString(str); CIDSystemInfo_dic.dictSet("Ordering", &ordering); +#endif CIDSystemInfo_dic.dictSet("Supplement", int_object(fdes->supplement)); +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + dic->dictSet("CIDSystemInfo", std::move(CIDSystemInfo_dic)); +#else dic->dictSet("CIDSystemInfo", &CIDSystemInfo_dic); +#endif dic->dictSet("DW", int_object(fwid->default_width)); } @@@@ -1249,8 +1557,12 @@@@ static Object *make_cidfont_dic( /* Get XREF table */ XRef *xref = doc->getXRef(); +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + Object *dic = new Object(new Dict(xref)); +#else Object *dic = new Object(); dic->initDict(xref); +#endif dic->dictSet("Type", name_object("Font")); dic->dictSet("Subtype", name_object("Type0")); @@@@ -1267,13 +1579,24 @@@@ static Object *make_cidfont_dic( dic->dictSet("Encoding", name_object(copyString(encoding))); Object obj; +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + obj = Object(fontdescriptor_obj_ref.num, fontdescriptor_obj_ref.gen); +#else obj.initRef(fontdescriptor_obj_ref.num, fontdescriptor_obj_ref.gen); +#endif Object array; +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 58 + array = Object(new Array(xref)); + array.arrayAdd(std::move(obj)); + + dic->dictSet("DescendantFonts", std::move(array)); +#else array.initArray(xref); array.arrayAdd(&obj); dic->dictSet("DescendantFonts", &array); +#endif return dic; } @ 1.1 log @Fix build with poppler 0.58 @ text @d1 1 a1 1 $NetBSD$ @