PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 9:36 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: PDF doucment cropping
PostPosted: Wed Sep 02, 2009 8:40 pm 
Offline

Joined: Wed Sep 02, 2009 8:29 pm
Posts: 2
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


Top
 Profile  
Reply with quote  
PostPosted: Thu Sep 03, 2009 7:22 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3095
Location: Cologne, Germany
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.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Fri Sep 04, 2009 7:40 pm 
Offline

Joined: Wed Sep 02, 2009 8:29 pm
Posts: 2
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


Top
 Profile  
Reply with quote  
PostPosted: Mon Sep 07, 2009 7:34 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3095
Location: Cologne, Germany
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).

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: Baidu [Spider] and 144 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group