Return to site

How To Crop Pdf In Preview

broken image


The documentclass options a4paper or letterpaper are certainly not the right choices when creating a set of equations or vector graphics using TiKZ for embedding in another document or standalone usage. Ideally, the output file is automatically set to fit its content, possibly with some whitespace around it.

The following post describes two possible ways:

The standalone documentclass

Really simple, instead of using a standard documentclass such as article or report, use standalone.

Crop pdf online


A simple example

I don't show the output here. Its a png-file showing some blind-text.


Options used

In the Preview app on your Mac, click the Show Markup Toolbar button (if the Markup toolbar isn't showing), then click the Rectangular Selection button. Select the portion of the page you want to keep. Click the Crop button in the Markup toolbar (or use the Touch Bar). Note: To undo the crop immediately, choose Edit Undo Crop.

How To Crop Pdf Image

If you find you have a multi-page PDF with huge margins on every page, you can use Preview to crop those margins down. With the PDF open in Preview, make sure that the sidebar is visible (in the View menu) and set it to display thumbnails using the button at the bottom. Worked great until I saved the PDF and reopened it in Preview. Once doing so, Preview showed all the pages as if they'd never been cropped. Skim (another PDF program) displays it correctly (all pages cropped to size), but not Preview. Browse other questions tagged pdf preview crop. The Overflow Blog How Stackers ditched the wiki and migrated to Articles. Featured on Meta Hot Meta Posts: Allow for.

How To Crop Pdf In Preview

  • varwidth: Uses linewidth as document-width. If the package is loaded without the option, all line-breaks are ignored.
  • border: Adds some whitespace around the content.
  • convert: Converts the output to png. Convert itself takes arguments such as size used in the example or the output image format extension. Loading the package without the option creates the output in pdf format. Standalone uses Image Magick (or Ghostscript) for conversion, different image formats are available. Please see the documentation for more information.

A full list of options is provided in the standalone bundle documentation. Interestingly, the background of the figure is transparent, which may not always be desirable. As the name already suggests, standalone is a bundle and has a lot more to offer than what is shown here. However, I hope this covers the most common usage.


A more fancy example

Crop Pdf Mac

The code was taken from A calendar of circles on TeXample.net. Again, the pdf output was converted to png using the standalone documentclass option convert in order to be able to embed it here.

TeXample.net has a great collection of pgf/TiKZ graphics. Go check it out if you haven't done so yet!


A graphic I recently created using the standalone documentclass and the adjustbox package:

Here is the pdf, perfectly scalable.

The preview package

Preview is a package rather than a document-class like standalone. Therefore, it has to be loaded in the preamble. Here is the same example given for standalone above:

How to create and email a zip file. Using PDFs will not affect the quality of the font and is perfectly scalable. I used 'png' here for visualization purposes. The quality is reasonable, but the figure is not scalable which is why it looks so bad here.

A few notes on the code

  • active: If not used, the package won't do anything.
  • PreviewBorder: Controls the whitespace around the content. Is set through setlength, as shown in the example.
  • preview-environment: An easy way to tell preview what to include. Another way would be to use an existing environment such as center by adding: PreviewEnvironment{center} to the preamble and using begin{center}..end{center}.

See the documentation for more details.

Under Linux or Mac OS X if Ghostscript is installed, use the following command in the terminal to convert pdf to png:





broken image