Crop white margins in a PDF file
Show older comments
Hi, I know this question has been asked already, but - so far - I did not find a suitable and easy solution.
I have a PDF file in a folder, which is actually a graph/figure.
I would like to programmatically read that PDF file and remove the margins/white space around my graph/figure.
Is there any simple but efficient way to do so (without changing figure ratio, size or quality)?
Something like this:
filename = open('mypdffile.pdf')
crop_margins(filename)
2 Comments
It would help if you provide an example of the file.
Unless you know for certain that it's not, I'd suspect that the padding is actually part of the image. Accumulating extra padding when saving plots is a very common problem.
If the padding is part of the image, then removing it will change the size of the image. Should the cropped image be rescaled to retain the original geometry?
Accepted Answer
More Answers (0)
Categories
Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

