1

I have a workflow that uses one of several tools that crop a generated pdf (either the standalone class with crop=true, or the pdfcrop or dvipng tools). In some cases I want to limit the cropping on one side. Currently, I'm achieving this by doing an \hspace then writing a period. That works, but I want to know if there are more elegant solutions. I just verified that (at least with the dvipng method) writing my period in white also works (\usepackage{xcolor}...\hspace{...}\textcolor{white}.). I also verified that using \hphantom and so on does not work: the extra space generated thereby will be cropped. Any other ideas about how to achieve this---if possible, without loading the xcolor package?

1

Use pdfcrop only

You can do this with pdfcrop with no need for the \hspace and period. For example...

pdfcrop --margins 10 0 0 0 in.pdf out.pdf

will leave a margin of 10 basic points on the left side of your pdf. The order of the --margins values are left, top, right, and bottom.

You can also add a white border to an already cropped pdf.

pdfcrop --margins 10 in.pdf out.pdf

You can even use a negative margin value to "overcrop", or crop more than the white border. This is especially useful if you need to crop away a box that surrounds your content.

  • Thanks, yes this could be an option. In my use-case, though, I have a number of documents where the ink takes up varying space. I want them all to have a constant width. To use the --margin flag on pdfcrop, I'd have to determine a different margin width for each. So not ideal for me. But for other workflows, this might be a good option. – dubiousjim Jan 4 '18 at 12:38
  • @dubiousjim: I see. Is it possible for you to simply use the geometry package to create your original PDF already having the correct width? – James Jan 4 '18 at 12:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.