Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pdftopdf: Backport 'pagesize_requested' field in ProcessingParameters struct #606

Open
wants to merge 1 commit into
base: 1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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