Reputation: 77
I've been looking for days to find a way how to read in an Advanced Function Presentation file in so that it writes out on the console some information about the file (e.g. how many documents, how many pages a document has...).
I have successfully read in the number of byte of the AFP file.
public static void main(String[] args) {
String filename = "xxx.afp";
try {
DataInputStream in = new DataInputStream(
new BufferedInputStream(
new FileInputStream(filename))))
System.out.println(in.read());
}
}
Thanks in advance!
Upvotes: 3
Views: 2798
Reputation: 11
The objects in an AFP file are tagged by so called triplets. You can think of them like 3-letter mnemonics. Typically they have a "begin" and "end" delimiter for the respective objects. The triplets are introduced by an eye-catcher byte sequence, 0x5A if I remember correctly (to be checked).
So, to count the pages you should go through your DataInputStream and count the occurrences of the "begin page" triplet. If you want to be very accurate you can try to match them with an "end page" triplet. The triplet specific hex values is something to check in the specification.
There are also commercial SDKs available.
Upvotes: 1
Reputation: 29129
Have you looked at AFP Renderer?
If this doesn't do what you want, then I am afraid that you are going to need to read the specifications, which you can get by following these instructions.
Upvotes: 2