Skip to content

Commit

Permalink
pdftopdf: Introduce 'pagesize_requested' field in the ProcessingParam…
Browse files Browse the repository at this point in the history
…eters struct

This commit backports from the master branch the implementation of the
'pagesize_requested' field in the parameters for pdftopdf processing.

Signed-off-by: Sergio Gómez <[email protected]>
  • Loading branch information
sergio-gdr authored and Sergio Gómez committed Nov 25, 2024
1 parent 6fd2bdf commit cdb887f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
8 changes: 8 additions & 0 deletions filter/pdftopdf/pdftopdf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,14 @@ void getParameters(ppd_file_t *ppd,int num_options,cups_option_t *options,Proces
param.autoprint = true;
}

// Certain features require a given page size for the page to be
// printed or all pages of the document being the same size. Here we
// set param.pagesize_requested so that the default page size is used
// when no size got specified by the user.
if (param.fitplot || param.fillprint || param.autoprint || param.autofit ||
param.booklet != BOOKLET_OFF || param.nup.nupX > 1 || param.nup.nupY > 1)
param.pagesize_requested = true;

if (ppd && (ppd->landscape < 0)) { // direction the printer rotates landscape (90 or -90)
param.normal_landscape=ROT_270;
} else {
Expand Down
8 changes: 7 additions & 1 deletion filter/pdftopdf/pdftopdf_processor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ bool processPDFTOPDF(PDFTOPDF_Processor &proc,ProcessingParameters &param) // {{
param.page.top = param.page.height;
}

if(param.fillprint||param.cropfit){
if (param.pagesize_requested && (param.fillprint || param.cropfit))
{
for(int i=0;i<(int)pages.size();i++)
{
std::shared_ptr<PDFTOPDF_PageHandle> page = pages[i];
Expand Down Expand Up @@ -330,6 +331,11 @@ bool processPDFTOPDF(PDFTOPDF_Processor &proc,ProcessingParameters &param) // {{
PageRect rect;
rect = page->getRect();
//rect.dump();
if (!param.pagesize_requested)
{
param.page.width = param.page.right = rect.width;
param.page.height = param.page.top = rect.height;
}

bool newPage=nupstate.nextPage(rect.width,rect.height,pgedit);
if (newPage) {
Expand Down
2 changes: 2 additions & 0 deletions filter/pdftopdf/pdftopdf_processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ struct ProcessingParameters {
ProcessingParameters()
: jobId(0),numCopies(1),
user(0),title(0),
pagesize_requested(false),
fitplot(false),
fillprint(false), //print-scaling = fill
cropfit(false),
Expand Down Expand Up @@ -59,6 +60,7 @@ ProcessingParameters()

int jobId, numCopies;
const char *user, *title; // will stay around
bool pagesize_requested;
bool fitplot;
bool fillprint; //print-scaling = fill
bool cropfit; // -o crop-to-fit
Expand Down

0 comments on commit cdb887f

Please sign in to comment.