PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Apr 25, 2024 5:22 am

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
PostPosted: Mon Nov 12, 2007 3:51 am 
Offline

Joined: Mon Nov 12, 2007 3:41 am
Posts: 4
Could someone please point me to sample code or sketch the key properties I'd need to access to determine (or even just get a reasonable estimate) of the size (in bytes) of one or more pages in a PDF?

I need to break existing PDFs into several smaller PDFs where each part should not exceed a specified size. These PDFs typically are just scanned documents, so the contents are image files, so maybe it's good enough if I can just find out (in code) the size of each page's image file, but it would be better to have a general solution that knows how big the entire page is.

Is it simply the size (in bytes) of the stream object that I want?

Once I know how to calculate/estimate page sizes, the code is simple: accumulate pages until the current page exceeds the threshold; save all the previous pages to a new file, and continue starting from the current page...

Thanks in advance for any help.

Chris


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 12, 2007 10:48 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
Chris Duncan wrote:
Is it simply the size (in bytes) of the stream object that I want?

A page can reference multiple objects (fonts, image, ...).
And objects can be referenced by multiple pages (fonts, logos, ...).

There is no simple solution (in general).

If you have a 1:1 relation between pages and images then you can go the easy way ...
... and take the sizes of the images.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Nov 12, 2007 4:10 pm 
Offline

Joined: Mon Nov 12, 2007 3:41 am
Posts: 4
Ok, so a general solution is not possible...

But yes, for the current project there is indeed a 1:1 correspondence between pages and images - these particular PDFs are just scanned documents, one image per page.

So, if you could give me an example of the object reference I need to get the size of an image on a page, that would be a big help (that is, it would save me a lot of time figuring out something that is hopefully already at your fingertips... I hope I'm not asking too much!).

Thanks,

Chris


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Nov 12, 2007 4:23 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
Well, it seems all you need to know (to solve this task) is in the ExportImages sample in the samples folder:
PDFsharp\Samples C#\ExportImages

_________________
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: Google [Bot] and 319 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