Java Code Examples for org.apache.pdfbox.pdmodel.PDDocument.getDocumentInformation()

The following are Jave code examples for showing how to use getDocumentInformation() of the org.apache.pdfbox.pdmodel.PDDocument class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: ctsms   File: PDFPainterBase.java   Source Code and License Vote up 7 votes
public void setMetadata(PDDocument doc) throws Exception {
	PDDocumentCatalog catalog = doc.getDocumentCatalog();
	PDDocumentInformation info = doc.getDocumentInformation();
	GregorianCalendar cal = new GregorianCalendar();
	cal.setTime(now);
	XMPMetadata metadata = new XMPMetadata();
	XMPSchemaPDF pdfSchema = metadata.addPDFSchema();
	pdfSchema.setKeywords(info.getKeywords());
	pdfSchema.setProducer(info.getProducer());
	XMPSchemaBasic basicSchema = metadata.addBasicSchema();
	basicSchema.setModifyDate(cal);
	basicSchema.setCreateDate(cal);
	basicSchema.setCreatorTool(info.getCreator());
	basicSchema.setMetadataDate(cal);
	XMPSchemaDublinCore dcSchema = metadata.addDublinCoreSchema();
	dcSchema.setTitle(info.getTitle());
	dcSchema.addCreator("PDFBox");
	dcSchema.setDescription(info.getSubject());
	PDMetadata metadataStream = new PDMetadata(doc);
	metadataStream.importXMPMetadata(metadata);
	catalog.setMetadata(metadataStream);
}
 
Example 2
Project: pdfbox   File: App.java   Source Code and License Vote up 5 votes
public static PDDocumentInformation pdf_info(String pdfPath) {

  PDDocument document = null;

  try {

    File input = new File(pdfPath);

    String filePath = input.getParent() + System.getProperty("file.separator");

    document = PDDocument.load(input);
    return(document.getDocumentInformation());

 } catch (IOException e) {
  return(null);
 }


}