Q:
How can I find the size, in bytes, of a single page of a PDF document?
A:
Measuring the "size" of a single page is complicated by the PDF
format, which allows multiple pages to each reference the same shared
object. (For more about the low-level details of the PDF format, kindly
see
http://www.pdftron.com/pdfnet/intro.html#sdf_obj.) So it's difficult to say what a single page's "size" is, exactly.
If
you're trying to measure the overall size of a file, you could use the
platform API get the size of the file or data stream. In case you need
to find byte size of a PDF document that is in process of being
generated (or edited) we do not have a way to telling the file size
upfront (i.e. before the file is serialized). You would need to save
the file (e.g. for example to a memory buffer), to find its data size.
In
theory, you could delete all pages besides the page you're trying to
measure, then save using e_remove_unused. The following code sample
shows how:
http://www.pdftron.com/pdfnet/samplecode.html#PDFPageThen
you could measure the size of that one-page file. That would show you
the size taken up by a single page, including all its shared resources.
However, whether this measure would be useful to you depends on what
you're trying to use the size measurement for.
If you are simply trying to reduce the size of the overall file, the Optimizer Add-On would be a far more
effective solution than trying to quantify the size of each individual
page. You can find sample code for using optimizer at:
http://www.pdftron.com/pdfnet/samplecode.html#Optimizer