How to get pdfcrop2 script

I am often interested in trimming pdfs, * and the one tool I use for this is the Heiko Oberdiek script pdfcrop.pl, I would like to try pdfcrop2fork pdfcrop.pl, but the Google Code Page (the only source of information I found about pdfcrop2) has only patches for the old version pdfcrop.plI can not find. Does anyone know where I can get a copy pdfcrop2or version 1.5 pdfcrop.pl?

* In addition to getting a working copy of pdfcrop2, I would be glad to know about any other tools (preferably Free) that you can use to trim pdf files. pdftkis fantastic for doing everything except cropping.

+4
source share
2 answers

Edit: full pdfcrop2 is available in the svn repository: http://code.google.com/p/pdfcrop2/source/browse/trunk/pdfcrop.pl

The original answer.

pdfcrop 1.5 was shipped with Debian and Ubuntu; a search in the texlive-bin source package for the file orig.tar.gz, which you can get from the nearest Debian mirror, should work.

+3
source

I played a little with pyPdf to set the page margins. Below are some test codes for creating PDF files with flat pages, setting the multimedia box and the trim box in the upper right to the same as on the first page, which could be the starting point for something more useful.

#!/usr/bin/python

from pyPdf import PdfFileWriter, PdfFileReader
from pdfsave import pdfSave
import sys

def pdfSetBoxes(input, output, mediaBox, cropBox):
    numPages = input.getNumPages()
    for pageNum in range(1,numPages, 2):
        page = input.getPage(pageNum)
        page.mediaBox.upperRight = mediaBox
        page.cropBox.upperRight = cropBox
        output.addPage(page)

input = PdfFileReader(file(sys.argv[1], "rb"))
output = PdfFileWriter()

page0 = input.getPage(0)
mb = page0.mediaBox.getUpperRight()
cb = page0.cropBox.getUpperRight()

pdfSetBoxes(input, output, mb, cb)
pdfSave(output, sys.argv[2])
+1

Source: https://habr.com/ru/post/1713309/


All Articles