org.zefer.pd4ml
Class PD4Document

java.lang.Object
  extended by org.zefer.pd4ml.PD4Document

public class PD4Document
extends java.lang.Object


Constructor Summary
PD4Document(byte[] bytes, java.lang.String password)
           
PD4Document(java.io.InputStream stream, java.lang.String password)
           
PD4Document(java.net.URL url, java.lang.String password)
           
 
Method Summary
 void append(PD4Document toMerge)
           
 java.lang.String getAuthor()
           
 java.lang.String getCreationDate()
           
 java.lang.String getCreator()
           
 java.lang.String getKeywords()
           
 java.lang.String getModDate()
           
 int getNumberOfPages()
           
 java.lang.String getPdfFormatVersion()
           
 int getPermissions()
           
 java.lang.String getProducer()
           
 java.lang.String getSubject()
           
 java.lang.String getTitle()
           
static void mergePDFs(java.io.InputStream pdf1, java.io.InputStream pdf2, java.io.OutputStream result)
          basic PDF mergeing method.
 void read()
          reads and parses given PDF document stream
 void setAuthor(java.lang.String author)
           
 void setCreator(java.lang.String creator)
           
 void setKeywords(java.lang.String keywords)
           
 void setModDate()
          sets the document modification date to "now"
 void setSubject(java.lang.String subject)
           
 void setTitle(java.lang.String title)
           
 void write(java.io.OutputStream out)
          writes current PDF document state to given output stream.
 void write(java.io.OutputStream out, java.lang.String password, int permissions)
          writes current PDF document state to given output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PD4Document

public PD4Document(byte[] bytes,
                   java.lang.String password)
            throws PD4InvokeException
Parameters:
bytes - PDF document as an array of bytes
password - if any. "null" for not protected PDF documents
Throws:
PD4InvokeException - by invalid call parameters

PD4Document

public PD4Document(java.io.InputStream stream,
                   java.lang.String password)
            throws PD4InvokeException
Parameters:
stream - PDF document input stream
password - if any. "null" for not protected PDF documents
Throws:
PD4InvokeException - by invalid call parameters

PD4Document

public PD4Document(java.net.URL url,
                   java.lang.String password)
            throws PD4InvokeException
Parameters:
url - PDF document URL
password - if any. "null" for not protected PDF documents
Throws:
PD4InvokeException - by invalid call parameters
Method Detail

write

public void write(java.io.OutputStream out)
           throws java.io.IOException
writes current PDF document state to given output stream.

Parameters:
out - an output stream to write to
Throws:
java.io.IOException - write errors

write

public void write(java.io.OutputStream out,
                  java.lang.String password,
                  int permissions)
           throws java.io.IOException,
                  PD4InvalidPasswordException
writes current PDF document state to given output stream.

Parameters:
out - an output stream to write to
password - password string. null if no password to be applied
permissions - PDF file access permissions See PD4Constants.Allow* constants. Example AllowAnnotate | AllowDegradedPrint. Use PD4Constants.DefaultPermissions for defaults.
Throws:
java.io.IOException - write errors
PD4InvalidPasswordException - invalid password given to the object constructor, i.e. PD4Document(byte[], String).

append

public void append(PD4Document toMerge)
            throws java.io.IOException
Parameters:
toMerge - another PDF document to append to the current one. Implicitly invokes read() if has not been triggered before.
Throws:
java.io.IOException - reflects a variety of PDF read/parse errors by read()
PD4InvalidPasswordException - invalid password given to the object constructor, i.e. PD4Document(byte[], String).

mergePDFs

public static void mergePDFs(java.io.InputStream pdf1,
                             java.io.InputStream pdf2,
                             java.io.OutputStream result)
                      throws java.io.IOException
basic PDF mergeing method. Appends pdf2 to pdf1 bytes and writes resulting PDF to result.

Parameters:
pdf1 - main PDF document bytes stream
pdf2 - PDF document bytes to append
result - output stream to write resulting PDF
Throws:
java.io.IOException - reflects a variety of PDF read/parse/write errors

getNumberOfPages

public int getNumberOfPages()
                     throws java.io.IOException,
                            PD4InvalidPasswordException
Returns:
returns a number of pages in the current PDF. Implicitly invokes read() if has not been triggered before.
Throws:
java.io.IOException - reflects a variety of PDF read/parse errors by read()
PD4InvalidPasswordException - invalid password given to the object constructor, i.e. PD4Document(byte[], String).

getPermissions

public int getPermissions()
                   throws java.io.IOException,
                          PD4InvalidPasswordException
Returns:
returns permissions flag of the document
Throws:
java.io.IOException - reflects a variety of PDF read/parse errors by read()
PD4InvalidPasswordException - invalid password given to the object constructor, i.e. PD4Document(byte[], String).

getTitle

public java.lang.String getTitle()
                          throws java.io.IOException,
                                 PD4InvalidPasswordException
Returns:
PDF "Title" metadata value (if any). Implicitly invokes read() if has not been triggered before.
Throws:
java.io.IOException - reflects a variety of PDF read/parse errors by read()
PD4InvalidPasswordException - invalid password given to the object constructor, i.e. PD4Document(byte[], String).

setTitle

public void setTitle(java.lang.String title)
              throws java.io.IOException,
                     PD4InvalidPasswordException
Parameters:
title - new document title. Implicitly invokes read() if has not been triggered before.
Throws:
java.io.IOException - reflects a variety of PDF read/parse errors by read()
PD4InvalidPasswordException - invalid password given to the object constructor, i.e. PD4Document(byte[], String).

getAuthor

public java.lang.String getAuthor()
                           throws java.io.IOException,
                                  PD4InvalidPasswordException
Throws:
java.io.IOException - reflects a variety of PDF read/parse errors by read()
PD4InvalidPasswordException - invalid password given to the object constructor, i.e. PD4Document(byte[], String).

setAuthor

public void setAuthor(java.lang.String author)
               throws java.io.IOException
Parameters:
author - a value to override document "Author" name. Implicitly invokes read() if has not been triggered before.
Throws:
java.io.IOException - reflects a variety of PDF read/parse errors by read()
PD4InvalidPasswordException - invalid password given to the object constructor, i.e. PD4Document(byte[], String).

getPdfFormatVersion

public java.lang.String getPdfFormatVersion()
                                     throws java.io.IOException,
                                            PD4InvalidPasswordException
Returns:
PDF format version from PDF document prefix.
Throws:
java.io.IOException - reflects a variety of PDF read/parse errors by read()
PD4InvalidPasswordException - invalid password given to the object constructor, i.e. PD4Document(byte[], String).

getCreationDate

public java.lang.String getCreationDate()
                                 throws java.io.IOException,
                                        PD4InvalidPasswordException
Returns:
PDF creation date as a string. Implicitly invokes read() if has not been triggered before.
Throws:
java.io.IOException - reflects a variety of PDF read/parse errors by read()
PD4InvalidPasswordException - invalid password given to the object constructor, i.e. PD4Document(byte[], String).

getKeywords

public java.lang.String getKeywords()
                             throws java.io.IOException,
                                    PD4InvalidPasswordException
Returns:
PDF "Keywords" metadata value (if any). Implicitly invokes read() if has not been triggered before.
Throws:
java.io.IOException - reflects a variety of PDF read/parse errors by read()
PD4InvalidPasswordException - invalid password given to the object constructor, i.e. PD4Document(byte[], String).

setKeywords

public void setKeywords(java.lang.String keywords)
                 throws java.io.IOException,
                        PD4InvalidPasswordException
Parameters:
keywords - a value to override document "Keywords" string. Implicitly invokes read() if has not been triggered before.
Throws:
java.io.IOException - reflects a variety of PDF read/parse errors by read()
PD4InvalidPasswordException - invalid password given to the object constructor, i.e. PD4Document(byte[], String).

getCreator

public java.lang.String getCreator()
                            throws java.io.IOException,
                                   PD4InvalidPasswordException
Returns:
PDF "Creator" metadata value (if any). Implicitly invokes read() if has not been triggered before.
Throws:
java.io.IOException - reflects a variety of PDF read/parse errors by read()
PD4InvalidPasswordException - invalid password given to the object constructor, i.e. PD4Document(byte[], String).

setCreator

public void setCreator(java.lang.String creator)
                throws java.io.IOException,
                       PD4InvalidPasswordException
Parameters:
creator - a value to override document "Creator" name. Implicitly invokes read() if has not been triggered before.
Throws:
java.io.IOException - reflects a variety of PDF read/parse errors by read()
PD4InvalidPasswordException - invalid password given to the object constructor, i.e. PD4Document(byte[], String).

getProducer

public java.lang.String getProducer()
                             throws java.io.IOException,
                                    PD4InvalidPasswordException
Returns:
PDF "Producer" metadata value (if any). Implicitly invokes read() if has not been triggered before.
Throws:
java.io.IOException - reflects a variety of PDF read/parse errors by read()
PD4InvalidPasswordException - invalid password given to the object constructor, i.e. PD4Document(byte[], String).

getSubject

public java.lang.String getSubject()
                            throws java.io.IOException,
                                   PD4InvalidPasswordException
Returns:
PDF "Subject" metadata value (if any). Implicitly invokes read() if has not been triggered before.
Throws:
java.io.IOException - reflects a variety of PDF read/parse errors by read()
PD4InvalidPasswordException - invalid password given to the object constructor, i.e. PD4Document(byte[], String).

setSubject

public void setSubject(java.lang.String subject)
                throws java.io.IOException,
                       PD4InvalidPasswordException
Parameters:
subject - a value to override document "Subject" string. Implicitly invokes read() if has not been triggered before.
Throws:
java.io.IOException - reflects a variety of PDF read/parse errors by read()
PD4InvalidPasswordException - invalid password given to the object constructor, i.e. PD4Document(byte[], String).

setModDate

public void setModDate()
                throws java.io.IOException,
                       PD4InvalidPasswordException
sets the document modification date to "now"

Throws:
java.io.IOException - reflects a variety of PDF read/parse errors by read()
PD4InvalidPasswordException - invalid password given to the object constructor, i.e. PD4Document(byte[], String).

getModDate

public java.lang.String getModDate()
                            throws java.io.IOException,
                                   PD4InvalidPasswordException
Returns:
Document modification date. Implicitly invokes read() if has not been triggered before.
Throws:
java.io.IOException - reflects a variety of PDF read/parse errors by read()
PD4InvalidPasswordException - invalid password given to the object constructor, i.e. PD4Document(byte[], String).

read

public void read()
          throws java.io.IOException,
                 PD4InvokeException,
                 PD4InvalidPasswordException
reads and parses given PDF document stream

Throws:
java.io.IOException - read/parsing errors
PD4InvokeException - PDF parsing specific errors
PD4InvalidPasswordException


Copyright © 2004-12 zefer.org. All Rights Reserved.