Skip to content

Commit

Permalink
TMP
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio Gómez committed Nov 24, 2024
1 parent eeee846 commit 029e70f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 16 deletions.
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
38 changes: 22 additions & 16 deletions filter/pdftopdf/pdftopdf_processor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -255,22 +255,23 @@ bool processPDFTOPDF(PDFTOPDF_Processor &proc,ProcessingParameters &param) // {{
param.page.top = param.page.height;
}

// if(param.fillprint||param.cropfit){
// for(int i=0;i<(int)pages.size();i++)
// {
// std::shared_ptr<PDFTOPDF_PageHandle> page = pages[i];
// Rotation orientation;
// if (page->is_landscape(param.orientation))
// orientation = param.normal_landscape;
// else
// orientation = ROT_0;
// page->crop(param.page, orientation, param.orientation,
// param.xpos, param.ypos,
// !param.cropfit, param.autoRotate);
// }
// if (param.fillprint)
// param.fitplot = true;
// }
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];
Rotation orientation;
if (page->is_landscape(param.orientation))
orientation = param.normal_landscape;
else
orientation = ROT_0;
page->crop(param.page, orientation, param.orientation,
param.xpos, param.ypos,
!param.cropfit, param.autoRotate);
}
if (param.fillprint)
param.fitplot = true;
}

std::shared_ptr<PDFTOPDF_PageHandle> curpage;
int outputpage=0;
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;
}

param.page.width = param.page.right = rect.width;
param.page.height = param.page.top = rect.height;
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 029e70f

Please sign in to comment.