Welcome Guest Search | Active Topics | Sign In | Register

Feature Request Options
Pete N
Posted: Sunday, January 20, 2013 3:03:47 PM
Rank: Newbie
Groups: Member

Joined: 1/20/2013
Posts: 2
Can we please have a way of getting the expected size of a PdfDocument.

Can get the exact size by actually saving it but this is slow. In a scenario where pages are being added until the file reaches a certain size it would be good to have an idea of how far we have got to.

This doesn't have to be very accurate. Within a K would be plenty. You could even add a bit to make sure you didn't get criticised for understating.

Rgds/Pete
eo_support
Posted: Sunday, January 20, 2013 3:14:38 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,071
Hi Pete,

Thanks for the feedback. In order to determine the document size, many internal data structure has to be converted/flattened. For example, font data has to be loaded and extracted from the system, then compressed; different subsets of the same font has to be merged, images has to be compressed, etc. These are effectively the same tasks needed to be done during the save process. It is not practical to run this process in the background while you are modifying the document.

The easiest way for you to determine document size is to call Save into a MemoryStream and then get that MemoryStream's length. You can call PdfDocument.Clone to make a clone of your original document particular for this purpose so that you can continue using your original PdfDocument for adding new contents.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.