Bladerunner
Bladerunner

Reputation: 97

How to get page size of a pdf bytearray with plain java code?

I have a bytearray of a pdf document.
Is it possible(without using any external libraries) to get to know how many pages the pdf contains?
Is it possible with only the use of java8?

I find it rather stupid that I have to import a whole pdf external library in my project for just getting to know the pagesize of a pdf.
There must be a way with just only using the java8 jdk, no?

Upvotes: 1

Views: 474

Answers (1)

Jordan
Jordan

Reputation: 2283

There must be a way with just only using the java8 jdk, no?

There are no objects in the base Java classes that understand PDF documents. I mean, you can technically look up the PDF spec and figure out how to write your own parser. It'll probably be weeks of work and thousands of lines of code. Or you can pull in a library, read some tutorials, and have this done in under half an hour.

One of the biggest advantages to coding in Java (besides the "write once, run anywhere" goal of the JVM) is that it's a very mature language with thousands and thousands of available libraries.

Upvotes: 4

Related Questions