This repository has been archived by the owner on Nov 29, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DumperMain.java: Utility that dumps XMP data of a PDF to standard out.
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.crossref.pdfmark; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.ByteArrayInputStream; | ||
import java.io.DataInputStream; | ||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
|
||
import com.lowagie.text.pdf.PdfReader; | ||
|
||
/** | ||
* Utility that dumps XMP data of a PDF to standard out. | ||
*/ | ||
public class DumperMain { | ||
|
||
public static void main(String[] args) { | ||
for (String filename : args) { | ||
|
||
File f = new File(filename); | ||
FileInputStream fileIn; | ||
PdfReader reader; | ||
|
||
try { | ||
fileIn = new FileInputStream(f); | ||
reader = new PdfReader(fileIn); | ||
byte[] merged = reader.getMetadata(); | ||
ByteArrayInputStream bIn = new ByteArrayInputStream(merged); | ||
BufferedReader bR = new BufferedReader(new InputStreamReader(bIn)); | ||
String line; | ||
while ((line = bR.readLine()) != null) { | ||
System.out.println(line); | ||
} | ||
|
||
reader.close(); | ||
fileIn.close(); | ||
} catch (IOException e) { | ||
System.err.println("Couldn't read file '" + filename + "'."); | ||
System.err.println(e); | ||
} | ||
} | ||
} | ||
|
||
} |