[poppler] Add trimbox support to pdftops

Albert Astals Cid aacid at kde.org
Mon Oct 18 14:38:53 PDT 2010


A Dilluns, 18 d'octubre de 2010, Benjamin Adler va escriure:
> Dear popplers,
> 
> I'd like to convert PDFs with high-res images and crop-marks to
> lower-res PDFs where the page-area outside of the cropping regions is
> white (no more cropmarks etc. visible). The cropping region is saved in
> the PDF as a TrimBox value (not CropBox or MediaBox).
> 
> To do this, I want to convert the PDFs using poppler's pdftops and crop
> them in that process. Lateron, I'll add some white border around the PDF
> (maybe embedding it with latex/pdfpages, not sure yet).
> 
> Instead of the -nocrop switch, I imagine sth. like
> 
> 	pdftops -crop [TrimBox|...|CropBox] in.pdf out.ps

Makes sense, though you want to let the -nocrop option there for backwards 
compatibility.

> As of now, poppler's pdftopsd only supports CropBox, not ArtBox, TrimBox
> or MediaBox. Looking at the source, it seems some parts of poppler have
> heard of these boxes before, some have not.
> 
> Whats the best way to patch this into poppler? I would have changed the
> signatures of Page::display and Page::displaySlice, Page::createGfx and
>   PDFDoc::displayPage* so that I can pass one value of the page_box_enum
> defined in poppler-global.h

That's wrong, that enum belongs to the cpp frontend, that is a layer above the 
poppler core, you need to define your enum inside poppler/poppler, maybe in 
Page.h? Otherwise seems a sensible idea.

> 
> - How would you do it?
> 
> - Why does Gfx's c'tor take both PDFRectangle *box and PDFRectangle
> *cropBox?

Because it let's you have a bigger box than your cropbox but still crop to the 
cropbox. (i think, we inherited that code from xpdf so you should ask its 
author about it to be sure).

Albert

> 
> thanks!
> ben
> _______________________________________________
> poppler mailing list
> poppler at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/poppler


More information about the poppler mailing list