Hi, Derek. This patch, written by Bernhard Link, suppresses PDF annotations when printing files (it is a feature patch). As I think that it is sensible to have, I'm sending it.
Regards, Rogério Brito. -- Rogério Brito : rbr...@{ime.usp.br,gmail.com} : GPG key 1024D/7C2CAEB8 http://rb.doesntexist.org : Packages for LaTeX : algorithms.berlios.de DebianQA: http://qa.debian.org/developer.php?login=rbrito%40ime.usp.br
diff -r -u xpdf-unstable/xpdf/OutputDev.h xpdf-patched/xpdf/OutputDev.h --- xpdf-unstable/xpdf/OutputDev.h 2007-02-27 23:05:52.000000000 +0100 +++ xpdf-patched/xpdf/OutputDev.h 2007-08-29 12:39:29.000000000 +0200 @@ -88,7 +88,8 @@ virtual GBool checkPageSlice(Page *page, double hDPI, double vDPI, int rotate, GBool useMediaBox, GBool crop, int sliceX, int sliceY, int sliceW, int sliceH, - GBool printing, Catalog *catalog, + GBool printing, GBool suppressAnnotations, + Catalog *catalog, GBool (*abortCheckCbk)(void *data) = NULL, void *abortCheckCbkData = NULL) { return gTrue; } diff -r -u xpdf-unstable/xpdf/Page.cc xpdf-patched/xpdf/Page.cc --- xpdf-unstable/xpdf/Page.cc 2007-02-27 23:05:52.000000000 +0100 +++ xpdf-patched/xpdf/Page.cc 2007-08-29 12:38:10.000000000 +0200 @@ -258,19 +258,20 @@ void Page::display(OutputDev *out, double hDPI, double vDPI, int rotate, GBool useMediaBox, GBool crop, - GBool printing, Catalog *catalog, + GBool printing, GBool suppressAnnotations, + Catalog *catalog, GBool (*abortCheckCbk)(void *data), void *abortCheckCbkData) { displaySlice(out, hDPI, vDPI, rotate, useMediaBox, crop, - -1, -1, -1, -1, printing, catalog, + -1, -1, -1, -1, printing, suppressAnnotations, catalog, abortCheckCbk, abortCheckCbkData); } void Page::displaySlice(OutputDev *out, double hDPI, double vDPI, int rotate, GBool useMediaBox, GBool crop, int sliceX, int sliceY, int sliceW, int sliceH, - GBool printing, Catalog *catalog, - GBool (*abortCheckCbk)(void *data), + GBool printing, GBool suppressAnnotations, + Catalog *catalog, GBool (*abortCheckCbk)(void *data), void *abortCheckCbkData) { #ifndef PDF_PARSER_ONLY PDFRectangle *mediaBox, *cropBox; @@ -283,7 +284,7 @@ if (!out->checkPageSlice(this, hDPI, vDPI, rotate, useMediaBox, crop, sliceX, sliceY, sliceW, sliceH, - printing, catalog, + printing, suppressAnnotations, catalog, abortCheckCbk, abortCheckCbkData)) { return; } @@ -319,29 +320,31 @@ } obj.free(); - // draw annotations - annotList = new Annots(xref, catalog, getAnnots(&obj)); - obj.free(); - acroForm = catalog->getAcroForm()->isDict() ? - catalog->getAcroForm()->getDict() : NULL; - if (acroForm) { - if (acroForm->lookup("NeedAppearances", &obj)) { - if (obj.isBool() && obj.getBool()) { - annotList->generateAppearances(acroForm); - } - } + if (!suppressAnnotations) { + // draw annotations + annotList = new Annots(xref, catalog, getAnnots(&obj)); obj.free(); - } - if (annotList->getNumAnnots() > 0) { - if (globalParams->getPrintCommands()) { - printf("***** Annotations\n"); + acroForm = catalog->getAcroForm()->isDict() ? + catalog->getAcroForm()->getDict() : NULL; + if (acroForm) { + if (acroForm->lookup("NeedAppearances", &obj)) { + if (obj.isBool() && obj.getBool()) { + annotList->generateAppearances(acroForm); + } + } + obj.free(); } - for (i = 0; i < annotList->getNumAnnots(); ++i) { - annotList->getAnnot(i)->draw(gfx, printing); + if (annotList->getNumAnnots() > 0) { + if (globalParams->getPrintCommands()) { + printf("***** Annotations\n"); + } + for (i = 0; i < annotList->getNumAnnots(); ++i) { + annotList->getAnnot(i)->draw(gfx, printing); + } + out->dump(); } - out->dump(); + delete annotList; } - delete annotList; delete gfx; #endif diff -r -u xpdf-unstable/xpdf/Page.h xpdf-patched/xpdf/Page.h --- xpdf-unstable/xpdf/Page.h 2007-02-27 23:05:52.000000000 +0100 +++ xpdf-patched/xpdf/Page.h 2007-08-29 13:11:15.000000000 +0200 @@ -151,7 +151,7 @@ // Display a page. void display(OutputDev *out, double hDPI, double vDPI, int rotate, GBool useMediaBox, GBool crop, - GBool printing, Catalog *catalog, + GBool printing, GBool suppressAnnotations, Catalog *catalog, GBool (*abortCheckCbk)(void *data) = NULL, void *abortCheckCbkData = NULL); @@ -159,7 +159,8 @@ void displaySlice(OutputDev *out, double hDPI, double vDPI, int rotate, GBool useMediaBox, GBool crop, int sliceX, int sliceY, int sliceW, int sliceH, - GBool printing, Catalog *catalog, + GBool printing, GBool suppressAnnotations, + Catalog *catalog, GBool (*abortCheckCbk)(void *data) = NULL, void *abortCheckCbkData = NULL); diff -r -u xpdf-unstable/xpdf/PDFCore.cc xpdf-patched/xpdf/PDFCore.cc --- xpdf-unstable/xpdf/PDFCore.cc 2007-02-27 23:05:52.000000000 +0100 +++ xpdf-patched/xpdf/PDFCore.cc 2007-08-29 13:48:33.000000000 +0200 @@ -832,7 +832,7 @@ } } doc->displayPageSlice(out, page->page, dpi, dpi, rotate, - gFalse, gTrue, gFalse, x, y, sliceW, sliceH); + gFalse, gTrue, gFalse, gFalse, x, y, sliceW, sliceH); tile->bitmap = out->takeBitmap(); memcpy(tile->ctm, out->getDefCTM(), 6 * sizeof(double)); memcpy(tile->ictm, out->getDefICTM(), 6 * sizeof(double)); @@ -842,7 +842,7 @@ if (!page->text) { if ((textOut = new TextOutputDev(NULL, gTrue, gFalse, gFalse))) { doc->displayPage(textOut, page->page, dpi, dpi, rotate, - gFalse, gTrue, gFalse); + gFalse, gTrue, gFalse, gFalse); page->text = textOut->takeText(); delete textOut; } @@ -1579,7 +1579,7 @@ } else { textOut = new TextOutputDev(NULL, gTrue, gFalse, gFalse); if (textOut->isOk()) { - doc->displayPage(textOut, pg, dpi, dpi, rotate, gFalse, gTrue, gFalse); + doc->displayPage(textOut, pg, dpi, dpi, rotate, gFalse, gTrue, gFalse, gFalse); textOut->cvtUserToDev(xMin, yMin, &x0, &y0); textOut->cvtUserToDev(xMax, yMax, &x1, &y1); if (x0 > x1) { @@ -1672,7 +1672,7 @@ for (pg = backward ? pg - 1 : pg + 1; backward ? pg >= 1 : pg <= doc->getNumPages(); pg += backward ? -1 : 1) { - doc->displayPage(textOut, pg, 72, 72, 0, gFalse, gTrue, gFalse); + doc->displayPage(textOut, pg, 72, 72, 0, gFalse, gTrue, gFalse, gFalse); if (textOut->findText(u, len, gTrue, gTrue, gFalse, gFalse, caseSensitive, backward, &xMin, &yMin, &xMax, &yMax)) { @@ -1685,7 +1685,7 @@ for (pg = backward ? doc->getNumPages() : 1; backward ? pg > topPage : pg < topPage; pg += backward ? -1 : 1) { - doc->displayPage(textOut, pg, 72, 72, 0, gFalse, gTrue, gFalse); + doc->displayPage(textOut, pg, 72, 72, 0, gFalse, gTrue, gFalse, gFalse); if (textOut->findText(u, len, gTrue, gTrue, gFalse, gFalse, caseSensitive, backward, &xMin, &yMin, &xMax, &yMax)) { diff -r -u xpdf-unstable/xpdf/PDFDoc.cc xpdf-patched/xpdf/PDFDoc.cc --- xpdf-unstable/xpdf/PDFDoc.cc 2007-02-27 23:05:52.000000000 +0100 +++ xpdf-patched/xpdf/PDFDoc.cc 2007-08-29 12:42:52.000000000 +0200 @@ -309,39 +309,43 @@ void PDFDoc::displayPage(OutputDev *out, int page, double hDPI, double vDPI, int rotate, GBool useMediaBox, GBool crop, GBool printing, + GBool suppressAnnotations, GBool (*abortCheckCbk)(void *data), void *abortCheckCbkData) { if (globalParams->getPrintCommands()) { printf("***** page %d *****\n", page); } catalog->getPage(page)->display(out, hDPI, vDPI, - rotate, useMediaBox, crop, printing, catalog, + rotate, useMediaBox, crop, printing, + suppressAnnotations, catalog, abortCheckCbk, abortCheckCbkData); } void PDFDoc::displayPages(OutputDev *out, int firstPage, int lastPage, double hDPI, double vDPI, int rotate, GBool useMediaBox, GBool crop, GBool printing, + GBool suppressAnnotations, GBool (*abortCheckCbk)(void *data), void *abortCheckCbkData) { int page; for (page = firstPage; page <= lastPage; ++page) { displayPage(out, page, hDPI, vDPI, rotate, useMediaBox, crop, printing, - abortCheckCbk, abortCheckCbkData); + suppressAnnotations, abortCheckCbk, abortCheckCbkData); } } void PDFDoc::displayPageSlice(OutputDev *out, int page, double hDPI, double vDPI, int rotate, GBool useMediaBox, GBool crop, GBool printing, + GBool suppressAnnotations, int sliceX, int sliceY, int sliceW, int sliceH, GBool (*abortCheckCbk)(void *data), void *abortCheckCbkData) { catalog->getPage(page)->displaySlice(out, hDPI, vDPI, rotate, useMediaBox, crop, sliceX, sliceY, sliceW, sliceH, - printing, catalog, + printing, suppressAnnotations, catalog, abortCheckCbk, abortCheckCbkData); } diff -r -u xpdf-unstable/xpdf/PDFDoc.h xpdf-patched/xpdf/PDFDoc.h --- xpdf-unstable/xpdf/PDFDoc.h 2007-02-27 23:05:52.000000000 +0100 +++ xpdf-patched/xpdf/PDFDoc.h 2007-08-29 12:41:43.000000000 +0200 @@ -89,6 +89,7 @@ void displayPage(OutputDev *out, int page, double hDPI, double vDPI, int rotate, GBool useMediaBox, GBool crop, GBool printing, + GBool suppressAnnotations, GBool (*abortCheckCbk)(void *data) = NULL, void *abortCheckCbkData = NULL); @@ -96,6 +97,7 @@ void displayPages(OutputDev *out, int firstPage, int lastPage, double hDPI, double vDPI, int rotate, GBool useMediaBox, GBool crop, GBool printing, + GBool suppressAnnotations, GBool (*abortCheckCbk)(void *data) = NULL, void *abortCheckCbkData = NULL); @@ -103,6 +105,7 @@ void displayPageSlice(OutputDev *out, int page, double hDPI, double vDPI, int rotate, GBool useMediaBox, GBool crop, GBool printing, + GBool suppressAnnotations, int sliceX, int sliceY, int sliceW, int sliceH, GBool (*abortCheckCbk)(void *data) = NULL, void *abortCheckCbkData = NULL); diff -r -u xpdf-unstable/xpdf/pdfimages.cc xpdf-patched/xpdf/pdfimages.cc --- xpdf-unstable/xpdf/pdfimages.cc 2007-02-27 23:05:52.000000000 +0100 +++ xpdf-patched/xpdf/pdfimages.cc 2007-08-29 13:48:33.000000000 +0200 @@ -135,7 +135,7 @@ imgOut = new ImageOutputDev(imgRoot, dumpJPEG); if (imgOut->isOk()) { doc->displayPages(imgOut, firstPage, lastPage, 72, 72, 0, - gFalse, gTrue, gFalse); + gFalse, gTrue, gFalse, gFalse); } delete imgOut; diff -r -u xpdf-unstable/xpdf/pdftoppm.cc xpdf-patched/xpdf/pdftoppm.cc --- xpdf-unstable/xpdf/pdftoppm.cc 2007-02-27 23:05:52.000000000 +0100 +++ xpdf-patched/xpdf/pdftoppm.cc 2007-08-29 12:50:34.000000000 +0200 @@ -34,6 +34,7 @@ static char cfgFileName[256] = ""; static GBool printVersion = gFalse; static GBool printHelp = gFalse; +static GBool suppressAnnotations = gFalse; static ArgDesc argDesc[] = { {"-f", argInt, &firstPage, 0, @@ -46,6 +47,8 @@ "generate a monochrome PBM file"}, {"-gray", argFlag, &gray, 0, "generate a grayscale PGM file"}, + {"-noannots", argFlag, &suppressAnnotations, 0, + "ommit annotations"}, #if HAVE_T1LIB_H {"-t1lib", argString, enableT1libStr, sizeof(enableT1libStr), "enable t1lib font rasterizer: yes, no"}, @@ -179,7 +182,7 @@ splashOut->startDoc(doc->getXRef()); for (pg = firstPage; pg <= lastPage; ++pg) { doc->displayPage(splashOut, pg, resolution, resolution, 0, - gFalse, gTrue, gFalse); + gFalse, gTrue, gFalse, suppressAnnotations); sprintf(ppmFile, "%.*s-%06d.%s", (int)sizeof(ppmFile) - 32, ppmRoot, pg, mono ? "pbm" : gray ? "pgm" : "ppm"); diff -r -u xpdf-unstable/xpdf/pdftops.cc xpdf-patched/xpdf/pdftops.cc --- xpdf-unstable/xpdf/pdftops.cc 2007-02-27 23:05:52.000000000 +0100 +++ xpdf-patched/xpdf/pdftops.cc 2007-08-29 13:48:33.000000000 +0200 @@ -60,6 +60,7 @@ static char cfgFileName[256] = ""; static GBool printVersion = gFalse; static GBool printHelp = gFalse; +static GBool suppressAnnotations = gFalse; static ArgDesc argDesc[] = { {"-f", argInt, &firstPage, 0, @@ -118,6 +119,8 @@ "owner password (for encrypted files)"}, {"-upw", argString, userPassword, sizeof(userPassword), "user password (for encrypted files)"}, + {"-noannots", argFlag, &suppressAnnotations, 0, + "ommit annotations"}, {"-q", argFlag, &quiet, 0, "don't print any messages or errors"}, {"-cfg", argString, cfgFileName, sizeof(cfgFileName), @@ -318,7 +321,8 @@ doc->getCatalog(), firstPage, lastPage, mode); if (psOut->isOk()) { doc->displayPages(psOut, firstPage, lastPage, 72, 72, - 0, !pageCrop, globalParams->getPSCrop(), gTrue); + 0, !pageCrop, globalParams->getPSCrop(), gTrue, + suppressAnnotations); } else { delete psOut; exitCode = 2; diff -r -u xpdf-unstable/xpdf/pdftotext.cc xpdf-patched/xpdf/pdftotext.cc --- xpdf-unstable/xpdf/pdftotext.cc 2007-02-27 23:05:52.000000000 +0100 +++ xpdf-patched/xpdf/pdftotext.cc 2007-08-29 13:48:33.000000000 +0200 @@ -47,6 +47,7 @@ static char cfgFileName[256] = ""; static GBool printVersion = gFalse; static GBool printHelp = gFalse; +static GBool suppressAnnotations = gFalse; static ArgDesc argDesc[] = { {"-f", argInt, &firstPage, 0, @@ -65,6 +66,8 @@ "output end-of-line convention (unix, dos, or mac)"}, {"-nopgbrk", argFlag, &noPageBreaks, 0, "don't insert page breaks between pages"}, + {"-noannots", argFlag, &suppressAnnotations, 0, + "ommit annotations"}, {"-opw", argString, ownerPassword, sizeof(ownerPassword), "owner password (for encrypted files)"}, {"-upw", argString, userPassword, sizeof(userPassword), @@ -235,7 +238,7 @@ physLayout, rawOrder, htmlMeta); if (textOut->isOk()) { doc->displayPages(textOut, firstPage, lastPage, 72, 72, 0, - gFalse, gTrue, gFalse); + gFalse, gTrue, gFalse, suppressAnnotations); } else { delete textOut; exitCode = 2; diff -r -u xpdf-unstable/xpdf/PSOutputDev.cc xpdf-patched/xpdf/PSOutputDev.cc --- xpdf-unstable/xpdf/PSOutputDev.cc 2007-02-27 23:05:52.000000000 +0100 +++ xpdf-patched/xpdf/PSOutputDev.cc 2007-08-29 12:39:07.000000000 +0200 @@ -2722,7 +2722,8 @@ int rotateA, GBool useMediaBox, GBool crop, int sliceX, int sliceY, int sliceW, int sliceH, - GBool printing, Catalog *catalog, + GBool printing, GBool suppressAnnotations, + Catalog *catalog, GBool (*abortCheckCbk)(void *data), void *abortCheckCbkData) { #if HAVE_SPLASH @@ -2743,7 +2744,8 @@ scan = new PreScanOutputDev(); page->displaySlice(scan, 72, 72, rotateA, useMediaBox, crop, sliceX, sliceY, sliceW, sliceH, - printing, catalog, abortCheckCbk, abortCheckCbkData); + printing, suppressAnnotations, + catalog, abortCheckCbk, abortCheckCbkData); rasterize = scan->usesTransparency(); delete scan; if (!rasterize) { @@ -2770,7 +2772,8 @@ page->displaySlice(splashOut, splashDPI, splashDPI, rotateA, useMediaBox, crop, sliceX, sliceY, sliceW, sliceH, - printing, catalog, abortCheckCbk, abortCheckCbkData); + printing, suppressAnnotations, + catalog, abortCheckCbk, abortCheckCbkData); // start the PS page page->makeBox(splashDPI, splashDPI, rotateA, useMediaBox, gFalse, diff -r -u xpdf-unstable/xpdf/PSOutputDev.h xpdf-patched/xpdf/PSOutputDev.h --- xpdf-unstable/xpdf/PSOutputDev.h 2007-02-27 23:05:52.000000000 +0100 +++ xpdf-patched/xpdf/PSOutputDev.h 2007-08-29 12:40:24.000000000 +0200 @@ -130,7 +130,8 @@ virtual GBool checkPageSlice(Page *page, double hDPI, double vDPI, int rotate, GBool useMediaBox, GBool crop, int sliceX, int sliceY, int sliceW, int sliceH, - GBool printing, Catalog *catalog, + GBool printing, GBool suppressAnnotations, + Catalog *catalog, GBool (*abortCheckCbk)(void *data) = NULL, void *abortCheckCbkData = NULL); diff -r -u xpdf-unstable/xpdf/XPDFViewer.cc xpdf-patched/xpdf/XPDFViewer.cc --- xpdf-unstable/xpdf/XPDFViewer.cc 2007-02-27 23:05:52.000000000 +0100 +++ xpdf-patched/xpdf/XPDFViewer.cc 2007-08-29 13:48:33.000000000 +0200 @@ -3161,7 +3161,7 @@ //------------------------------------------------------------------------ void XPDFViewer::initPrintDialog() { - Widget sep1, sep2, row, label1, label2, okBtn, cancelBtn; + Widget sep1, sep2, sep3, row, label1, label2, okBtn, cancelBtn; Arg args[20]; int n; XmString s; @@ -3287,10 +3287,37 @@ sep2 = XmCreateSeparator(printDialog, "sep2", args, n); XtManageChild(sep2); - //----- "print" and "cancel" buttons + //----- "suppress Annotations" n = 0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); ++n; XtSetArg(args[n], XmNtopWidget, sep2); ++n; + XtSetArg(args[n], XmNtopOffset, 4); ++n; + XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); ++n; + XtSetArg(args[n], XmNindicatorType, XmONE_OF_MANY); ++n; + XtSetArg(args[n], XmNset, XmUNSET); ++n; + s = XmStringCreateLocalized("Suppress annotations (even those marked as printable)"); + XtSetArg(args[n], XmNlabelString, s); ++n; + suppressAnnotationsBtn = XmCreateToggleButton(printDialog, "suppressAnnotations", args, n); + XmStringFree(s); + XtManageChild(suppressAnnotationsBtn); + + //----- separator + n = 0; + XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); ++n; + XtSetArg(args[n], XmNtopWidget, suppressAnnotationsBtn); ++n; + XtSetArg(args[n], XmNtopOffset, 8); ++n; + XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); ++n; + XtSetArg(args[n], XmNleftOffset, 8); ++n; + XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); ++n; + XtSetArg(args[n], XmNrightOffset, 8); ++n; + XtSetArg(args[n], XmNorientation, XmHORIZONTAL); ++n; + sep3 = XmCreateSeparator(printDialog, "sep3", args, n); + XtManageChild(sep3); + + //----- "print" and "cancel" buttons + n = 0; + XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); ++n; + XtSetArg(args[n], XmNtopWidget, sep3); ++n; XtSetArg(args[n], XmNtopOffset, 8); ++n; XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); ++n; XtSetArg(args[n], XmNleftOffset, 4); ++n; @@ -3302,7 +3329,7 @@ &printPrintCbk, (XtPointer)this); n = 0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); ++n; - XtSetArg(args[n], XmNtopWidget, sep2); ++n; + XtSetArg(args[n], XmNtopWidget, sep3); ++n; XtSetArg(args[n], XmNtopOffset, 8); ++n; XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); ++n; XtSetArg(args[n], XmNrightOffset, 4); ++n; @@ -3362,6 +3389,7 @@ if (psFileName) { delete psFileName; } + XmToggleButtonSetState(suppressAnnotationsBtn, False, False); sprintf(buf, "%d", doc->getNumPages()); XmTextFieldSetString(printFirstPage, "1"); @@ -3399,7 +3427,7 @@ void XPDFViewer::printPrintCbk(Widget widget, XtPointer ptr, XtPointer callData) { XPDFViewer *viewer = (XPDFViewer *)ptr; - unsigned char withCmd; + unsigned char withCmd, suppressAnnotations; GString *psFileName; int firstPage, lastPage; PDFDoc *doc; @@ -3433,13 +3461,15 @@ } else if (lastPage > doc->getNumPages()) { lastPage = doc->getNumPages(); } + XtVaGetValues(viewer->suppressAnnotationsBtn, XmNset, &suppressAnnotations, NULL); psOut = new PSOutputDev(psFileName->getCString(), doc->getXRef(), doc->getCatalog(), firstPage, lastPage, psModePS); if (psOut->isOk()) { doc->displayPages(psOut, firstPage, lastPage, 72, 72, - 0, gTrue, globalParams->getPSCrop(), gTrue); + 0, gTrue, globalParams->getPSCrop(), gTrue, + suppressAnnotations?gTrue:gFalse); } delete psOut; delete psFileName; diff -r -u xpdf-unstable/xpdf/XPDFViewer.h xpdf-patched/xpdf/XPDFViewer.h --- xpdf-unstable/xpdf/XPDFViewer.h 2007-02-27 23:05:52.000000000 +0100 +++ xpdf-patched/xpdf/XPDFViewer.h 2007-08-29 13:03:24.000000000 +0200 @@ -347,6 +347,7 @@ Widget printFileText; Widget printFirstPage; Widget printLastPage; + Widget suppressAnnotationsBtn; }; #endif