Home  Products  Purchase  Downloads  Demos  Forums  Blogs  Ticket  Wiki  API  Corporate

com.aspose.pdf.kit
Class PdfFileInfo

java.lang.Object
  extended bycom.aspose.pdf.kit.PdfFileInfo

public class PdfFileInfo
extends java.lang.Object

Represents a class for accessing meta information of Pdf file.

 [SampleCode]
 PdfFileInfo fileInfo = new PdfFileInfo(inFile);
 System.out.println("TITLE: " + fileInfo.getTitle());
 System.out.println("AUTHOR:" + fileInfo.getAuthor());
 System.out.println("CREATIONDATE:" + fileInfo.getCreationDate());
 System.out.println("CREATOR:" + fileInfo.getCreator());
 System.out.println("KeyWORDS:" + fileInfo.getKeywords());
 System.out.println("MODDATE:" + fileInfo.getModDate());
 HashMap header = fileInfo.getHeader();
 Object[] headerKeys = header.keySet().toArray();
 for (int hIndex = 0; hIndex < headerKeys.length; hIndex++) {
 System.out.println(headerKeys[hIndex].toString() + ":" + header.get(headerKeys[hIndex].toString()));
 }
 


Constructor Summary
PdfFileInfo(java.io.InputStream inputStream)
          Creates a PdfFileInfo object instance, and reads input Pdf Stream.
PdfFileInfo(java.lang.String inputFile)
          Creates a PdfFileInfo object instance, and reads input Pdf file.
 
Method Summary
 boolean beEncrypted()
          Checkes whether the Pdf file is encrypted.
 void clearInfo()
          Clears all changeable information of Pdf file.
 java.lang.String getAuthor()
          Gets the Author information of Pdf file.
 java.lang.String getCreationDate()
          Gets the CreationDate information of Pdf file.
 java.lang.String getCreator()
          Gets the Creator information of Pdf file.
 java.util.HashMap getHeader()
          Gets the customized information of Pdf file.
 java.lang.String getKeywords()
          Gets the Keywords information of Pdf file.
 java.lang.String getMetaInfo(java.lang.String name)
          Gets customized information of Pdf file with property name.
 java.lang.String getModDate()
          Gets the modified date information of Pdf file.
 int getNumberofPages()
          Gets the number of file pages.
 float getPageHeight(int pageNum)
          Gets the height size of the specified page.
 int getPageRotation(int pageNum)
          Gets the rotation of the specified page.
 float getPageWidth(int pageNum)
          Gets the width size of the specified page.
 java.lang.String getProducer()
          Gets the Producer information of Pdf file.
 java.lang.String getSubject()
          Gets the Subject information of Pdf file.
 java.lang.String getTitle()
          Gets the Title information of Pdf file.
 boolean saveNewInfo(java.io.OutputStream outStream)
          Changes the properties specified explicitly by setting file information, other properties remain.
 boolean saveNewInfo(java.lang.String outputFile)
          Changes the meta-information specified explicitly by setting file information, other information remains.
 void setAuthor(java.lang.String author)
          Sets the Author information of Pdf file.
 void setCreator(java.lang.String creator)
          Sets the Creator information of Pdf file.
 void setHeader(java.util.HashMap header)
          Sets the customized information of Pdf file.
 void setKeywords(java.lang.String keywords)
          Sets the Keywords information of Pdf file.
 void setMetaInfo(java.lang.String name, java.lang.String value)
          Sets customized information of Pdf file with property name and property value.
 void setSubject(java.lang.String subject)
          Sets the Subject information of Pdf file.
 void setTitle(java.lang.String title)
          Sets the Title information of Pdf file.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PdfFileInfo

public PdfFileInfo(java.lang.String inputFile)
            throws java.io.IOException
Creates a PdfFileInfo object instance, and reads input Pdf file.

Parameters:
inputFile - String Input Pdf file path.
Throws:
java.io.IOException

PdfFileInfo

public PdfFileInfo(java.io.InputStream inputStream)
            throws java.io.IOException
Creates a PdfFileInfo object instance, and reads input Pdf Stream.

Parameters:
inputStream - InputStream Input Pdf Stream.
Throws:
java.io.IOException
Method Detail

getNumberofPages

public int getNumberofPages()
Gets the number of file pages.

Returns:
int - Number of file page.

beEncrypted

public boolean beEncrypted()
Checkes whether the Pdf file is encrypted.

Returns:
boolean - Indicates whether encrypted, true for encrypted, otherwise false.

getAuthor

public java.lang.String getAuthor()
Gets the Author information of Pdf file.

Returns:
String - The author of the file.

setAuthor

public void setAuthor(java.lang.String author)
Sets the Author information of Pdf file.

Parameters:
author - String New author of the file.

getTitle

public java.lang.String getTitle()
Gets the Title information of Pdf file.

Returns:
String - The title infomation of Pdf file.

setTitle

public void setTitle(java.lang.String title)
Sets the Title information of Pdf file.

Parameters:
title - String New Title infomation of Pdf file.

getSubject

public java.lang.String getSubject()
Gets the Subject information of Pdf file.

Returns:
String - the Subject information of Pdf file.

setSubject

public void setSubject(java.lang.String subject)
Sets the Subject information of Pdf file.

Parameters:
subject - String New Subject information of Pdf file.

getCreator

public java.lang.String getCreator()
Gets the Creator information of Pdf file.

Returns:
String The Creator information of Pdf file.

setCreator

public void setCreator(java.lang.String creator)
Sets the Creator information of Pdf file.

Parameters:
creator - String New Creator information of Pdf file.

getKeywords

public java.lang.String getKeywords()
Gets the Keywords information of Pdf file.

Returns:
String - Keywords information of Pdf file.

setKeywords

public void setKeywords(java.lang.String keywords)
Sets the Keywords information of Pdf file.

Parameters:
keywords - String New Keywords information of Pdf file.

getHeader

public java.util.HashMap getHeader()
Gets the customized information of Pdf file.

Returns:
HashMap - Customized meta information of Pdf file.

setHeader

public void setHeader(java.util.HashMap header)
Sets the customized information of Pdf file.

Parameters:
header - HashMap New customized meta information of Pdf file.

getCreationDate

public java.lang.String getCreationDate()
Gets the CreationDate information of Pdf file.

Returns:
String - CreationDate of Pdf file.

getProducer

public java.lang.String getProducer()
Gets the Producer information of Pdf file.

Returns:
String - Producer information of Pdf file.

getModDate

public java.lang.String getModDate()
Gets the modified date information of Pdf file.

Returns:
String - Modified data information of Pdf file.

saveNewInfo

public boolean saveNewInfo(java.lang.String outputFile)
                    throws java.io.IOException,
                           PdfKitException,
                           java.io.IOException
Changes the meta-information specified explicitly by setting file information, other information remains.

Parameters:
outputFile - String Output Pdf file name.
Returns:
boolean - True for success, or false.
Throws:
java.io.IOException
PdfKitException
java.io.IOException

saveNewInfo

public boolean saveNewInfo(java.io.OutputStream outStream)
                    throws PdfKitException,
                           java.io.IOException
Changes the properties specified explicitly by setting file information, other properties remain.

 [SampleCode]
 String inFile = "example1.pdf";
 String outFile = "kitOut.pdf";
 HashMap header = new HashMap();
 header.put("Zone", "+800");
 PdfFileInfo fileInfo = new PdfFileInfo(inFile);
 fileInfo.setAuthor("William");
 fileInfo.setTitle("Hello");
 fileInfo.setSubject("Peace");
 fileInfo.setKeywords("A,B");
 fileInfo.setHeader(null);
 fileInfo.saveNewInfo(outFile);
 

Parameters:
outStream - OutputStream Output Pdf Stream.
Returns:
boolean - True for success, or false.
Throws:
PdfKitException
java.io.IOException

clearInfo

public void clearInfo()
Clears all changeable information of Pdf file.


getPageHeight

public float getPageHeight(int pageNum)
                    throws java.io.IOException
Gets the height size of the specified page.

Parameters:
pageNum - int Indicate the page.
Returns:
float - The height of the page.
Throws:
java.io.IOException

getPageWidth

public float getPageWidth(int pageNum)
                   throws java.io.IOException
Gets the width size of the specified page.

Parameters:
pageNum - int Indicate the page.
Returns:
float - The width of the page.
Throws:
java.io.IOException

getPageRotation

public int getPageRotation(int pageNum)
                    throws java.lang.Exception
Gets the rotation of the specified page.

Parameters:
pageNum - int Indicate which page.
Returns:
int - The rotation of the page.The value may be 0,90,180,270.
Throws:
java.lang.Exception

getMetaInfo

public java.lang.String getMetaInfo(java.lang.String name)
Gets customized information of Pdf file with property name. If there is no property match the name, it will return a blank string.

Parameters:
name - meta property's name.
Returns:
meta property's value.

setMetaInfo

public void setMetaInfo(java.lang.String name,
                        java.lang.String value)
Sets customized information of Pdf file with property name and property value.

Parameters:
name - meta property's name.
value - meta property's value.