Hi,
On Monday 23 October 2006 06:42, Jeff Muizelaar wrote:
> On Sun, Oct 22, 2006 at 12:11:01PM +0200, Sascha Sommer wrote:
> > Hello,
> >
> > I went through the xpdf changes that were done in cups and tried to port
> > them to poppler.
> >
> > poppler-0.5.4_psheader_fix.patch seems to be necessary to get a valid
> > postscript header.
>
> It'd be nice to have more information on what this all changes and why
> it is needed.
>
If I understand the patch correctly it summarizes common headers for
psModePS, psModeEPS, psModeForm. In addition to that it adds Creator and Title
information to the ps. Without this patch the ps (at least generated with the
pdftops from cups) will not work with gs.
> > poppler-0.5.4_renderHiddenAnnotations.patch adds a new function to
> > OutputDev.h that can be overwritten to disable rendering of hidden
> > annotations. I did not find a pdf to test, therefore this hunk is
> > untested.
>
> A pdf to test would be nice.
>
I don't have one either. I only extracted the changes from cups pdftops.
> > dict = str->streamGetDict();
> >
> > + // get annotation flags and only print annotations that are hidden or
> > + // don't have the print bit set.
> > + dict->lookup("F", &flagsObj);
>
> This comment doesn't make much sense to me...
>
I updated it in the attached patch
> > poppler-0.5.4_renderPage.patch adds the function renderPage to OutputDev.
> > It will be called by Gfx.cc for every page to check if the selected page
> > should be printed. With this patch it is possible to render only a subset
> > of the available pages.
>
> This reminds me of the stuff the KDE people wanted. I am not a huge fan
> of this change because it further encourages the use of the raw poppler
> api which really doesn't have any sort of stability guarantees.
>
> It'd be better if CUPS used one of supported APIs. If adding extra
> depenecies on things like glib or qt is a problem I imagine it would be
> easy to add a straight forward c binding. My guess is that CUPS just
> uses poppler/xpdf for pdf to postscript conversion. So it wouldn't be
> tough to do.
>
The idea for this change was to have something like:
class cupsPSOutputDev: public PSOutputDev {
public:
cupsPSOutputDev(char *fileName, XRef *xrefA, Catalog *catalog,
int firstPage, int lastPage, PSOutMode modeA,
int paperWidthA = -1, int paperHeightA = -1,GBool duplexA = gTrue,
int imgLLXA = 0, int imgLLYA = 0,int imgURXA = 0, int imgURYA = 0,
GBool manualCtrlA = gFalse, my_additional_options_go_here)
: PSOutputDev(fileName,xrefA,catalog,firstPage,lastPage,modeA,
paperWidthA,paperHeightA,duplexA, imgLLXA, imgLLYA, imgURXA,
imgURYA, manualCtrlA){
}
GBool renderHiddenAnnotations(){
return gFalse;
}
GBool renderPage(int page){
check if the page should be rendered
return (gFalse);
}
}
Cups needs something similar to the renderPage option to exclude certain pages
afaik.
> Michael, I notice you are on the CC. Do you have any thoughts about what
> kind of API you would like to see from poppler for use by CUPS?
>
I ccd him because http://cups.org/str.php?L1471+P0+S-2+C0+I0+E0+Qpoppler
is probably not the best place to discuss poppler changes.
Regards
Sascha
diff -Naur poppler-0.5.4.org/poppler/Gfx.cc poppler-0.5.4/poppler/Gfx.cc
--- poppler-0.5.4.org/poppler/Gfx.cc 2006-10-09 09:40:58.000000000 +0200
+++ poppler-0.5.4/poppler/Gfx.cc 2006-10-09 09:41:17.000000000 +0200
@@ -3318,18 +3318,36 @@
void Gfx::doAnnot(Object *str, double xMin, double yMin,
double xMax, double yMax) {
Dict *dict, *resDict;
- Object matrixObj, bboxObj, resObj;
+ Object matrixObj, bboxObj, resObj, flagsObj;;
Object obj1;
double m[6], bbox[6], ictm[6];
double *ctm;
double formX0, formY0, formX1, formY1;
double annotX0, annotY0, annotX1, annotY1;
double det, x, y, sx, sy;
- int i;
+ int i, flags;
// get stream dict
dict = str->streamGetDict();
+ // get annotation flags to check for annotations that are hidden or
+ // don't have the print bit set.
+ dict->lookup("F", &flagsObj);
+ if (flagsObj.isInt()) {
+ flags = flagsObj.getInt();
+ } else {
+ // Print anything that doesn't have any flags set...
+ flags = 4;
+ }
+ flagsObj.free();
+
+// fprintf(stderr, "DEBUG: doAnnot found annotation with flags = %x\n",flags);
+
+ if (!out->renderHiddenAnnotations() && ((flags & 2) == 2 || (flags & 4) == 0)) {
+ // Don't print hidden or no-print annotations...
+ return;
+ }
+
// get the form bounding box
dict->lookup("BBox", &bboxObj);
if (!bboxObj.isArray()) {
diff -Naur poppler-0.5.4.org/poppler/OutputDev.h poppler-0.5.4/poppler/OutputDev.h
--- poppler-0.5.4.org/poppler/OutputDev.h 2006-10-09 09:40:58.000000000 +0200
+++ poppler-0.5.4/poppler/OutputDev.h 2006-10-09 09:41:17.000000000 +0200
@@ -76,6 +76,7 @@
// Should the page be rendered
virtual GBool renderPage(int /*pageNum*/) { return gTrue; }
+ virtual GBool renderHiddenAnnotations() { return gTrue; }
// Start a page.
virtual void startPage(int /*pageNum*/, GfxState * /*state*/) {}
_______________________________________________
poppler mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/poppler