PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.com/

PDF doucment cropping
http://forum.pdfsharp.com/viewtopic.php?f=2&t=858
Page 1 of 1

Author:  billxie [ Wed Sep 02, 2009 8:40 pm ]
Post subject:  PDF doucment cropping

I need to adjust the margin of a pdf document so as to remove the unwanted blank space all arounds. It is like cropping a portion of a PDF document. Here are the questions:

1. How to figure out the max height and width of a nonblank area.
2. Given a rect of the area for cropping, what are the functions to copy the area to another pdf document? XImage.DrawImage has an overload with source rect and dest rect, but I found it does not work.

Can anybody help me out of these questions?

Thanks

Author:  Thomas Hoevel [ Thu Sep 03, 2009 7:22 am ]
Post subject:  Re: PDF doucment cropping

A PDF file has several boxes you can set: IIRC MediaBox, BleedBox, CropBox, ArtBox, ...
So IIRC you only have to set the CropBox, that's all.
This is a property of class PdfPage.

Author:  billxie [ Fri Sep 04, 2009 7:40 pm ]
Post subject:  Re: PDF doucment cropping

Seems MediaBox, CropBox can only change the view of the PDF, i.e., the view is change when you open PDF in Acrobat Reader. When I use DrawImage to draw an XImage from this PDF file, it will still draw the whole picture.

1. Is there any way to make the view resulted from CropBox effective in DrawImage
2. DrawImage has many overloads, one having source rect and dest rect, I tried that, but source rect never works, is it a bug?
3. Is there anyway to move part of the PDF document (delimited by Rect) to another location?

thanks

Author:  Thomas Hoevel [ Mon Sep 07, 2009 7:34 am ]
Post subject:  Re: PDF doucment cropping

billxie wrote:
1. Is there any way to make the view resulted from CropBox effective in DrawImage
2. DrawImage has many overloads, one having source rect and dest rect, I tried that, but source rect never works, is it a bug?
3. Is there anyway to move part of the PDF document (delimited by Rect) to another location?

Re 2: this is not yet implemented (and I was told there is no simple way to do it)
Re 3: there is no simple way to deal with the partially visible items.
Re 1: AFAIK the parameters come from GDI+ originally, but there is no easy way to implement a source rectangle in PDF. As a hack, you can draw white rectangles to hide what shall be hidden (but some flickering may be visible).

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/