We all know how big a PDF file is in bytes, but how big is each page?
To answer this, you need to understand a little about the contents of a PDF file and how a file is constructed. A PDF file is a dump of PDF objects. It consists of the objects themselves and a trailer – metadata so that each object can be found. The objects usually consist of a set of key values and often a compressed binary stream of data. The binary data is usually image data or colour data or the set of instructions used to draw the page. The data is decompressed in memory when the object is read.
A page itself does not have a size – you cannot say it starts at a certain point and ends at another. What you could say however is that a page consists of a set of objects:-
1. The Page objects which describe the page and contain the binary stream of page instructions used to contruct its contents.
2. The local Resources objects which contains colors, fonts and images used on the page.
3. Global Resource objects (which may be used on any page) and also consist of colors, fonts and images.
4. A proportion of the PDF file metadata.
The last item is probably small enough that it can be reasonably ignored and we can also reasonably ignore the non-binary content of the objects.
So a good guess for a pagesize is the sum of the binary streams which might be used on it. The compressed size probably provides a good guess as to the PDF page size in the PDF file and the uncompressed size might well be an equally good guess at how much an unrendered page (ie not drawn) would use in memory if you needed that.
Our software libraries allow you to
|Convert PDF files to HTML
|Use PDF Forms in a web browser
|Convert PDF Documents to an image
|Work with PDF Documents in Java
|Read and write HEIC and other Image formats in Java