diff -Nru cups-filters-1.0.24/debian/changelog cups-filters-1.0.24/debian/changelog --- cups-filters-1.0.24/debian/changelog 2012-09-25 06:21:33.000000000 +0200 +++ cups-filters-1.0.24/debian/changelog 2012-11-29 17:11:56.000000000 +0100 @@ -1,3 +1,18 @@ +cups-filters (1.0.24-2ubuntu0.1) quantal-proposed; urgency=low + + * debian/patches/pdftopdf-landscape-fix.patch: Auto-rotate functionality + added to pdftopdf to print landscape-formatted PDFs (for example from + LibreOffice) correctly (LP: #1040037, Upstream bug #1080). + * debian/patches/pdftopdf-multiple-copies-collate-fix.patch: The pdftopdf + filter started the second copy of a duplex job with an odd number of + pages on the back side of the last page of the first copy. Thanks to + David Williams from Ricoh for reporting this and to Tobias Hoffmann for + fixing this (LP: #1084534). + * debian/rules: Added "DEB_DH_FIXPERMS_ARGS := -Xusr/lib/cups/backend" to not + correct the permissions of CUPS backends (LP: #1076786). + + -- Till Kamppeter Thu, 29 Nov 2012 16:59:59 +0100 + cups-filters (1.0.24-2) experimental; urgency=low * debian/patches/texttopdf-fix-deficient-string-escaping.patch: Fixed diff -Nru cups-filters-1.0.24/debian/patches/pdftopdf-landscape-fix.patch cups-filters-1.0.24/debian/patches/pdftopdf-landscape-fix.patch --- cups-filters-1.0.24/debian/patches/pdftopdf-landscape-fix.patch 1970-01-01 01:00:00.000000000 +0100 +++ cups-filters-1.0.24/debian/patches/pdftopdf-landscape-fix.patch 2012-11-29 17:08:07.000000000 +0100 @@ -0,0 +1,149 @@ +--- a/filter/pdftopdf/pdftopdf.cc ++++ b/filter/pdftopdf/pdftopdf.cc +@@ -323,6 +323,7 @@ + param.page.width=pagesize->width; + param.page.height=pagesize->length; + } ++ param.paper_is_landscape=(param.page.width>param.page.height); + + PageRect tmp; // borders (before rotation) + +@@ -489,6 +490,10 @@ + + // TODO? pdftopdf* ? + // TODO?! pdftopdfAutoRotate ++ ++ // TODO?! choose default by whether pdfautoratate filter has already been run (e.g. by mimetype) ++ param.autoRotate=( !is_false(cupsGetOption("pdfAutoRotate",num_options,options)) && ++ !is_false(cupsGetOption("pdftopdfAutoRotate",num_options,options)) ); + } + // }}} + +--- a/filter/pdftopdf/pdftopdf_processor.cc ++++ b/filter/pdftopdf/pdftopdf_processor.cc +@@ -43,6 +43,9 @@ + Rotation_dump(orientation); + fprintf(stderr,"\n"); + ++ fprintf(stderr,"paper_is_landscape: %s\n", ++ (paper_is_landscape)?"true":"false"); ++ + fprintf(stderr,"duplex: %s\n", + (duplex)?"true":"false"); + +@@ -89,6 +92,9 @@ + fprintf(stderr,"\nbooklet signature: %d\n", + bookSignature); + ++ fprintf(stderr,"autoRotate: %s\n", ++ (autoRotate)?"true":"false"); ++ + fprintf(stderr,"emitJCL: %s\n", + (emitJCL)?"true":"false"); + fprintf(stderr,"deviceCopies: %d\n", +@@ -149,6 +155,11 @@ + return false; + } + ++ if (param.autoRotate) { ++ const bool dst_lscape=( param.paper_is_landscape==( (param.orientation==ROT_0)||(param.orientation==ROT_180) ) ); ++ proc.autoRotateAll(dst_lscape,param.normal_landscape); ++ } ++ + std::vector> pages=proc.get_pages(); + const int numOrigPages=pages.size(); + +--- a/filter/pdftopdf/pdftopdf_processor.h ++++ b/filter/pdftopdf/pdftopdf_processor.h +@@ -15,6 +15,7 @@ + user(0),title(0), + fitplot(false), + orientation(ROT_0),normal_landscape(ROT_270), ++ paper_is_landscape(false), + duplex(false), + border(NONE), + reverse(false), +@@ -31,6 +32,8 @@ + + booklet(BOOKLET_OFF),bookSignature(-1), + ++ autoRotate(false), ++ + emitJCL(true),deviceCopies(1),deviceReverse(false), + deviceCollate(false),setDuplex(false) + { +@@ -51,6 +54,7 @@ + bool fitplot; + PageRect page; + Rotation orientation,normal_landscape; // normal_landscape (i.e. default direction) is e.g. needed for number-up=2 ++ bool paper_is_landscape; + bool duplex; + BorderType border; + NupParameters nup; +@@ -71,6 +75,8 @@ + BookletMode booklet; + int bookSignature; + ++ bool autoRotate; ++ + // ppd/jcl changes + bool emitJCL; + int deviceCopies; +@@ -123,6 +129,7 @@ + + virtual void multiply(int copies,bool collate) =0; + ++ virtual void autoRotateAll(bool dst_lscape,Rotation normal_landscape) =0; // TODO elsewhere?! + virtual void addCM(const char *defaulticc,const char *outputicc) =0; + + virtual void setComments(const std::vector &comments) =0; +--- a/filter/pdftopdf/qpdf_pdftopdf_processor.cc ++++ b/filter/pdftopdf/qpdf_pdftopdf_processor.cc +@@ -439,7 +439,36 @@ + } + } + // }}} +- ++ ++// TODO? elsewhere? ++void QPDF_PDFTOPDF_Processor::autoRotateAll(bool dst_lscape,Rotation normal_landscape) // {{{ ++{ ++ assert(pdf); ++ ++ const int len=orig_pages.size(); ++ for (int iA=0;iAret.height); ++ if (src_lscape!=dst_lscape) { ++ Rotation rotation=normal_landscape; ++ // TODO? other rotation direction, e.g. if (src_rot==ROT_0)&&(param.orientation==ROT_270) ... etc. ++ // rotation=ROT_270; ++ ++ page.replaceOrRemoveKey("/Rotate",makeRotate(src_rot+rotation)); ++ } ++ } ++} ++// }}} ++ + #include "qpdf_cm.h" + + // TODO +--- a/filter/pdftopdf/qpdf_pdftopdf_processor.h ++++ b/filter/pdftopdf/qpdf_pdftopdf_processor.h +@@ -48,6 +48,7 @@ + + virtual void multiply(int copies,bool collate); + ++ virtual void autoRotateAll(bool dst_lscape,Rotation normal_landscape); + virtual void addCM(const char *defaulticc,const char *outputicc); + + virtual void setComments(const std::vector &comments); diff -Nru cups-filters-1.0.24/debian/patches/pdftopdf-multiple-copies-collate-fix.patch cups-filters-1.0.24/debian/patches/pdftopdf-multiple-copies-collate-fix.patch --- cups-filters-1.0.24/debian/patches/pdftopdf-multiple-copies-collate-fix.patch 1970-01-01 01:00:00.000000000 +0100 +++ cups-filters-1.0.24/debian/patches/pdftopdf-multiple-copies-collate-fix.patch 2012-10-18 23:23:23.000000000 +0200 @@ -0,0 +1,279 @@ +--- a/filter/pdftopdf/pdftopdf.cc ++++ b/filter/pdftopdf/pdftopdf.cc +@@ -30,27 +30,6 @@ + + // namespace {} + +-struct PrinterFeatures { +- PrinterFeatures() : canCollate(false) +- {} +-// TODO: ppd->manual_copies +- +- bool canCollate; +-// bool +-}; +- +-PrinterFeatures getPrinterFeatures(ppd_file_t *ppd) +-{ +- PrinterFeatures ret; +- if (!ppd) { +- return ret; +- } +-/* +- +-*/ +- return ret; +-} +- + void setFinalPPD(ppd_file_t *ppd,const ProcessingParameters ¶m) + { + if ( (param.booklet==BOOKLET_ON)&&(ppdFindOption(ppd,"Duplex")) ) { +@@ -71,27 +50,12 @@ + choice->marked=0; + } + +- // hardware can't collate the way we want it. Thus we collate; printer shall not +- if (param.unsetCollate) { +- ppdMarkOption(ppd,"Collate","False"); ++ // TODO: FIXME: unify code with emitJCLOptions, which does this "by-hand" now (and makes this code superfluous) ++ if (param.deviceCopies==1) { ++ // make sure any hardware copying is disabled ++ ppdMarkOption(ppd,"Copies","1"); ++ ppdMarkOption(ppd,"JCLCopies","1"); + } +- +-#if 0 +- if (ppd) { +- if (ppd->manual_copies) { +- // disable any hardware copying +- ppdMarkOption(ppd,"Copies","1"); +- ppdMarkOption(ppd,"JCLCopies","1"); +- } else { +- // use hardware copying +- param.deviceCopies=param.numCopies; +- param.numCopies=1; +- } +- } +-#else +- ppdMarkOption(ppd,"Copies","1"); +- ppdMarkOption(ppd,"JCLCopies","1"); +-#endif + } + + // for choice, only overwrites ret if found in ppd +@@ -515,7 +479,8 @@ + // }}} + */ + +- // make pages a multiple of two (only considered when duplex is on). ++ // make pages a multiple of two (only considered when duplex is on). ++ // i.e. printer has hardware-duplex, but needs pre-inserted filler pages + // FIXME? pdftopdf also supports it as cmdline option (via checkFeature()) + ppd_attr_t *attr; + if ( (attr=ppdFindAttr(ppd,"cupsEvenDuplex",0)) != NULL) { +@@ -527,11 +492,23 @@ + } + // }}} + +-void calculate(ppd_file_t *ppd,ProcessingParameters ¶m) ++static bool printerWillCollate(ppd_file_t *ppd) // {{{ + { +- // First step: no device copies, no device collate, no device reverse. ++ ppd_choice_t *choice; ++ ++ if ( ( (choice=ppdFindMarkedChoice(ppd,"Collate")) != NULL)&& ++ (is_true(choice->choice)) ) { ++ ++ // printer can collate, but also for the currently marked ppd features? ++ ppd_option_t *opt=ppdFindOption(ppd,"Collate"); ++ return (opt)&&(!opt->conflicted); ++ } ++ return false; ++} ++// }}} + +-// TODO? better ++void calculate(ppd_file_t *ppd,ProcessingParameters ¶m) // {{{ ++{ + param.deviceReverse=false; + if (param.reverse) { + // test OutputOrder of hardware (ppd) +@@ -543,67 +520,51 @@ + param.evenDuplex=true; // disabled later, if non-duplex + } + } +-/* +- TODO: +- force collate for duplex and not hw-collate +- +- TODO: +- +- // check collate device +- if (P2PDoc::options.collate && !ppd->manual_copies) { +- if ((choice = ppdFindMarkedChoice(ppd,"Collate")) != NULL && +- !strcasecmp(choice->choice,"true")) { +- ppd_option_t *opt; +- +- if ((opt = ppdFindOption(ppd,"Collate")) != NULL && +- !opt->conflicted) { +- deviceCollate = gTrue; +- } else { +- ppdMarkOption(ppd,"Collate","False"); +- } +- } +- } +- +-see also setFinalPPD() +-*/ + + if (param.numCopies==1) { + // collate is not needed + param.collate=false; // does not make a big difference for us +- param.unsetCollate=true; + } +-/* TODO? ++/* TODO? instead: + if (...numOutputPages==1 [after nup,evenDuplex!]) { + param.collate=false; // does not make a big difference for us +- param.unsetCollate=true; // TODO: is this worth it? + } + */ + +- // TODO: other possibility would be: if (param.collate) { param.collate=false; param.unsetCollate=false; } +- param.unsetCollate=true; +- +- if ( (param.collate)&&(!param.unsetCollate) ) { // TODO? +- param.evenDuplex=true; ++#if 0 // for now ++ // enable hardware copy generation ++ if (ppd) { ++ if (!ppd->manual_copies) { ++ // use hardware copying ++ param.deviceCopies=param.numCopies; ++ param.numCopies=1; ++ } else { ++ param.deviceCopies=1; ++ } + } ++#endif + +- if (!param.duplex) { +- param.evenDuplex=false; +- } ++ setFinalPPD(ppd,param); + +- // not needed yet: TODO +- // param.deviceCopies=1; +- // ppd->manual_copies=1; // ?? ++ // check collate device, with current ppd settings ++ if (param.collate) { ++ if (param.deviceCopies==1) { // e.g. ppd->manual_copies ++ param.deviceCollate=false; ++ } else { ++ param.deviceCollate=printerWillCollate(ppd); ++ } + +- setFinalPPD(ppd,param); // TODO? elsewhere/outside +-} ++ if (!param.deviceCollate) { ++ ppdMarkOption(ppd,"Collate","False"); // disable any hardware-collate ++ param.evenDuplex=true; // software collate always needs fillers ++ } ++ } + +-void dump_options(int num_options,cups_option_t *options) +-{ +- fprintf(stderr,"%d options:\n",num_options); +- for (int iA=0;iA + +-// TODO: -currently changes ppd. ++// TODO: -currently changes ppd. (Copies) + // + static void emitJCLOptions(FILE *fp, ppd_file_t *ppd, int deviceCopies) // {{{ + { +@@ -168,7 +168,7 @@ + snprintf(buf,sizeof(buf),"%d",param.deviceCopies); + output.push_back(std::string("%%PDFTOPDFNumCopies : ")+buf); + +- if ( (param.collate)&&(!param.unsetCollate) ) { ++ if (param.deviceCollate) { + output.push_back("%%PDFTOPDFCollate : true"); + } else { + output.push_back("%%PDFTOPDFCollate : false"); +--- a/filter/pdftopdf/pdftopdf_processor.cc ++++ b/filter/pdftopdf/pdftopdf_processor.cc +@@ -73,6 +73,10 @@ + + fprintf(stderr,"collate: %s\n", + (collate)?"true":"false"); ++ ++ fprintf(stderr,"evenDuplex: %s\n", ++ (evenDuplex)?"true":"false"); ++ + /* + // std::string pageLabel; // or NULL? must stay/dup! + ... +@@ -85,17 +89,16 @@ + fprintf(stderr,"\nbooklet signature: %d\n", + bookSignature); + +- fprintf(stderr,"evenDuplex: %s\n", +- (evenDuplex)?"true":"false"); +- + fprintf(stderr,"emitJCL: %s\n", + (emitJCL)?"true":"false"); + fprintf(stderr,"deviceCopies: %d\n", + deviceCopies); ++ fprintf(stderr,"deviceReverse: %s\n", ++ (deviceReverse)?"true":"false"); ++ fprintf(stderr,"deviceCollate: %s\n", ++ (deviceCollate)?"true":"false"); + fprintf(stderr,"setDuplex: %s\n", + (setDuplex)?"true":"false"); +- fprintf(stderr,"unsetCollate: %s\n", +- (unsetCollate)?"true":"false"); + } + // }}} + +--- a/filter/pdftopdf/pdftopdf_processor.h ++++ b/filter/pdftopdf/pdftopdf_processor.h +@@ -32,7 +32,7 @@ + booklet(BOOKLET_OFF),bookSignature(-1), + + emitJCL(true),deviceCopies(1),deviceReverse(false), +- setDuplex(false),unsetCollate(false) ++ deviceCollate(false),setDuplex(false) + { + page.width=612.0; // letter + page.height=792.0; +@@ -71,14 +71,13 @@ + BookletMode booklet; + int bookSignature; + ++ // ppd/jcl changes + bool emitJCL; + int deviceCopies; + bool deviceReverse; +- +- // ppd changes ++ bool deviceCollate; + bool setDuplex; + // unsetMirror (always) +- bool unsetCollate; + + // helper functions + bool withPage(int outno) const; // 1 based diff -Nru cups-filters-1.0.24/debian/patches/series cups-filters-1.0.24/debian/patches/series --- cups-filters-1.0.24/debian/patches/series 2012-09-25 06:21:33.000000000 +0200 +++ cups-filters-1.0.24/debian/patches/series 2012-11-29 17:05:26.000000000 +0100 @@ -1 +1,3 @@ texttopdf-fix-deficient-string-escaping.patch +pdftopdf-multiple-copies-collate-fix.patch +pdftopdf-landscape-fix.patch diff -Nru cups-filters-1.0.24/debian/rules cups-filters-1.0.24/debian/rules --- cups-filters-1.0.24/debian/rules 2012-09-25 06:21:33.000000000 +0200 +++ cups-filters-1.0.24/debian/rules 2012-11-29 17:20:20.000000000 +0100 @@ -23,6 +23,7 @@ #DEB_DH_STRIP_ARGS := --dbg-package=cups-filters-dbg DEB_DH_INSTALL_SOURCEDIR := debian/tmp +DEB_DH_FIXPERMS_ARGS := -Xusr/lib/cups/backend DPKG_GENSYMBOLS_CHECK_LEVEL=4 export DPKG_GENSYMBOLS_CHECK_LEVEL