View previous topic :: View next topic |
Author |
Message |
Chris Duncan
Joined: 12 Nov 2007 Posts: 4
|
Posted: Mon Nov 12, 2007 3:51 am Post subject: Page sizes (bytes, not inches)? |
|
|
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 |
|
Back to top |
|
|
Thomas Hoevel
Joined: 16 Oct 2006 Posts: 387 Location: Cologne, Germany
|
Posted: Mon Nov 12, 2007 10:48 am Post subject: Re: Page sizes (bytes, not inches)? |
|
|
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 |
|
Back to top |
|
|
Chris Duncan
Joined: 12 Nov 2007 Posts: 4
|
Posted: Mon Nov 12, 2007 4:10 pm Post subject: |
|
|
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 |
|
Back to top |
|
|
Thomas Hoevel
Joined: 16 Oct 2006 Posts: 387 Location: Cologne, Germany
|
Posted: Mon Nov 12, 2007 4:23 pm Post subject: |
|
|
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 |
|
Back to top |
|
|
|