Hi! I'm trying to write a program to convert a batch of images in PDF files(1 picture - 1 file) to JPEG. The pictures are cocooned with a "header" and a "footer" and if I just remove them and rename the filename to JPG I get just what I want.
The problem starts with removing these headers and footers.
In my PDF files I have:
...bunch of PDF bytes..
.stream....bunch of JPG bytes...
.endstream...more PDF bytes...
So my idea was this:
1. take the first 1000 bytes, convert them to
String and find the index of the keyword "stream"
2. take the last 1000 bytes, convert them to String and find the index of the keyword "endstream"
This way I get the beginning and the end of my JPG file so I can use the code JPEG data and put it in my JPG file.
This is some code I started with:
I keep getting an IndexOutOfBoundsException on this line:
and I can't figure out why?
I would also like to know if you think my way of thinking is OK
Cheers