Project

General

Profile

1
package eu.dnetlib.iis.metadataextraction;
2

    
3
import java.io.File;
4
import java.io.FileInputStream;
5
import java.io.InputStream;
6
import java.security.InvalidParameterException;
7
import org.jdom.Element;
8
import org.jdom.output.Format;
9
import org.jdom.output.XMLOutputter;
10
import pl.edu.icm.cermine.ContentExtractor;
11

    
12
/**
13
 * Metadata extractor main class executing extraction 
14
 * for all files provided as arguments.
15
 * @author mhorst
16
 *
17
 */
18
public class MetadataExtractorMain {
19

    
20
	public static void main(String[] args) throws Exception {
21
		if (args.length>0) {
22
			for (String fileLoc : args) {
23
				ContentExtractor extractor = new ContentExtractor();
24
				InputStream inputStream = new FileInputStream(new File(fileLoc));
25
				try {
26
                    extractor.uploadPDF(inputStream);
27
					Element resultElem = extractor.getNLMContent();
28
					XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());
29
					System.out.println(outputter.outputString(resultElem));
30
					System.out.println();
31
				} finally {
32
					inputStream.close();
33
				}
34
			}
35
		} else {
36
			throw new InvalidParameterException("no pdf file path provided");
37
		}
38
	}
39

    
40
}
(3-3/8)