|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.zefer.pd4ml.npdf.PD4DocumentBase
public abstract class PD4DocumentBase
Field Summary | |
---|---|
protected byte[] |
bytes
|
protected short |
debug
|
protected boolean |
newDocument
|
protected PD4DocumentBase |
overlay
|
protected boolean[] |
overlayDestScope
|
protected int |
overlayOpacity
|
protected boolean[] |
overlaySrcScope
|
protected java.lang.String |
password
|
PdfDocument |
pdf
|
protected boolean |
reassignedToAnotherDocument
|
protected java.io.InputStream |
stream
|
protected PD4DocumentBase |
toMerge
|
protected boolean |
underlayFlag
|
protected java.net.URL |
url
|
Constructor Summary | |
---|---|
protected |
PD4DocumentBase()
|
|
PD4DocumentBase(byte[] bytes,
java.lang.String password)
|
|
PD4DocumentBase(java.io.InputStream stream,
java.lang.String password)
|
|
PD4DocumentBase(java.net.URL url,
java.lang.String password)
|
Method Summary | |
---|---|
void |
append(PD4DocumentBase toMerge)
|
static boolean[] |
computeScope(java.lang.String scope,
int pageNum)
Utility method converts page scope description to a boolean array of flags. |
int |
deletePage(int pageNumber)
deletes a page of a loaded document. |
java.lang.String |
dumpOutlines()
|
java.lang.String |
getAuthor()
|
java.lang.String |
getCreationDate()
|
java.lang.String |
getCreator()
|
java.lang.String |
getKeywords()
|
java.lang.String |
getModDate()
|
int |
getNumberOfPages()
|
protected int |
getObjectCounter()
|
java.lang.String |
getPageContent(int pageIndex)
|
java.lang.String |
getPdfFormatVersion()
|
int |
getPermissions()
|
java.lang.String |
getProducer()
|
java.lang.String |
getSubject()
|
java.lang.String |
getTitle()
|
void |
overlay(PD4DocumentBase anotherDoc,
int opacity)
|
void |
overlay(PD4DocumentBase anotherDoc,
java.lang.String srcScope,
java.lang.String destScope,
int opacity)
|
void |
read()
reads and parses given PDF document stream |
protected abstract void |
read(int objectCounter)
reads and parses given PDF document stream |
protected void |
readIfNeeded()
checks if read() has been already invoked. |
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 |
underlay(PD4DocumentBase anotherDoc,
int opacity)
|
void |
underlay(PD4DocumentBase anotherDoc,
java.lang.String srcScope,
java.lang.String destScope,
int opacity)
|
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 |
Field Detail |
---|
protected java.io.InputStream stream
protected java.net.URL url
protected byte[] bytes
protected java.lang.String password
protected short debug
public PdfDocument pdf
protected PD4DocumentBase toMerge
protected PD4DocumentBase overlay
protected boolean[] overlaySrcScope
protected boolean[] overlayDestScope
protected int overlayOpacity
protected boolean underlayFlag
protected boolean newDocument
protected boolean reassignedToAnotherDocument
Constructor Detail |
---|
protected PD4DocumentBase()
public PD4DocumentBase(byte[] bytes, java.lang.String password) throws PD4InvokeException
bytes
- PDF document as an array of bytespassword
- if any. "null" for not protected PDF documents
PD4InvokeException
- by invalid call parameterspublic PD4DocumentBase(java.io.InputStream stream, java.lang.String password) throws PD4InvokeException
stream
- PDF document input streampassword
- if any. "null" for not protected PDF documents
PD4InvokeException
- by invalid call parameterspublic PD4DocumentBase(java.net.URL url, java.lang.String password) throws PD4InvokeException
url
- PDF document URLpassword
- if any. "null" for not protected PDF documents
PD4InvokeException
- by invalid call parametersMethod Detail |
---|
public void write(java.io.OutputStream out) throws java.io.IOException, PD4InvokeException
out
- an output stream to write to
java.io.IOException
- write errors
PD4InvokeException
- if the document is already appended to another one (document objects reassigned to another root).public void write(java.io.OutputStream out, java.lang.String password, int permissions) throws java.io.IOException, PD4InvokeException, PD4InvalidPasswordException
out
- an output stream to write topassword
- password string. null if no password to be appliedpermissions
- PDF file access permissions See PD4Constants.Allow* constants.
Example AllowAnnotate | AllowDegradedPrint. Use PD4Constants#DefaultPermissions
for defaults.
java.io.IOException
- write errors
PD4InvalidPasswordException
- invalid password given to the object constructor, i.e. #PD4Document(byte[], String)
.
PD4InvokeException
- if the document is already appended to another one (document objects reassigned to another root).public void append(PD4DocumentBase toMerge) throws java.io.IOException
toMerge
- another PDF document to append to the current one. Implicitly invokes read()
if has not been triggered before.
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)
.
PD4InvokeException
- by an attempt to merge with more than one documentpublic void overlay(PD4DocumentBase anotherDoc, int opacity) throws java.io.IOException
anotherDoc
- another PDF document whose page content is to be combined with the pages of the current document. Implicitly invokes read()
if has not been triggered before.
The method applies all pages of anotherDoc to all pages of this doc.opacity
- transparency of the overlay: 0 = fully transparent, 255 (or any negative value) = opaque
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)
.
PD4InvokeException
- by an attempt to merge with more than one documentcomputeScope(String, int)
public void overlay(PD4DocumentBase anotherDoc, java.lang.String srcScope, java.lang.String destScope, int opacity) throws java.io.IOException
anotherDoc
- another PDF document whose page content is to be combined with the pages of the current document. Implicitly invokes read()
if has not been triggered before.srcScope
- a page range of an overlay document to use.destScope
- a page range in the current document the overlay is to apply to.opacity
- transparency of the overlay: 0 = fully transparent, 255 (or any negative value) = opaque
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)
.
PD4InvokeException
- by an attempt to merge with more than one documentcomputeScope(String, int)
public void underlay(PD4DocumentBase anotherDoc, int opacity) throws java.io.IOException
anotherDoc
- another PDF document whose page content is to be placed under of the current document content. Implicitly invokes read()
if has not been triggered before.
The method applies all pages of anotherDoc to all pages of this doc.opacity
- transparency of the overlay: 0 = fully transparent, 255 (or any negative value) = opaque
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)
.
PD4InvokeException
- by an attempt to merge with more than one documentcomputeScope(String, int)
public void underlay(PD4DocumentBase anotherDoc, java.lang.String srcScope, java.lang.String destScope, int opacity) throws java.io.IOException
anotherDoc
- another PDF document whose page content is to be placed under of the current document content. Implicitly invokes read()
if has not been triggered before.srcScope
- a page range of an underlay document to use.destScope
- a page range in the current document the underlay is to apply to.opacity
- transparency of the overlay: 0 = fully transparent, 255 (or any negative value) = opaque
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)
.
PD4InvokeException
- by an attempt to merge with more than one documentcomputeScope(String, int)
protected void readIfNeeded() throws java.io.IOException, PD4InvalidPasswordException
read()
has been already invoked. Invokes if not.
java.io.IOException
PD4InvalidPasswordException
- invalid password given to the object constructor, i.e. #PD4Document(byte[], String)
.public int getNumberOfPages() throws java.io.IOException, PD4InvalidPasswordException
read()
if has not been triggered before.
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)
.public int getPermissions() throws java.io.IOException, PD4InvalidPasswordException
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)
.public java.lang.String getTitle() throws java.io.IOException, PD4InvalidPasswordException
read()
if has not been triggered before.
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)
.public void setTitle(java.lang.String title) throws java.io.IOException, PD4InvalidPasswordException
title
- new document title. Implicitly invokes read()
if has not been triggered before.
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)
.public java.lang.String getAuthor() throws java.io.IOException, PD4InvalidPasswordException
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)
.public void setAuthor(java.lang.String author) throws java.io.IOException
author
- a value to override document "Author" name. Implicitly invokes read()
if has not been triggered before.
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)
.public java.lang.String getPdfFormatVersion() throws java.io.IOException, PD4InvalidPasswordException
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)
.public java.lang.String getCreationDate() throws java.io.IOException, PD4InvalidPasswordException
read()
if has not been triggered before.
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)
.public java.lang.String dumpOutlines() throws java.io.IOException, PD4InvalidPasswordException
read()
if has not been triggered before.
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)
.public java.lang.String getKeywords() throws java.io.IOException, PD4InvalidPasswordException
read()
if has not been triggered before.
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)
.public void setKeywords(java.lang.String keywords) throws java.io.IOException, PD4InvalidPasswordException
keywords
- a value to override document "Keywords" string. Implicitly invokes read()
if has not been triggered before.
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)
.public java.lang.String getCreator() throws java.io.IOException, PD4InvalidPasswordException
read()
if has not been triggered before.
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)
.public void setCreator(java.lang.String creator) throws java.io.IOException, PD4InvalidPasswordException
creator
- a value to override document "Creator" name. Implicitly invokes read()
if has not been triggered before.
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)
.public java.lang.String getProducer() throws java.io.IOException, PD4InvalidPasswordException
read()
if has not been triggered before.
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)
.public java.lang.String getSubject() throws java.io.IOException, PD4InvalidPasswordException
read()
if has not been triggered before.
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)
.public void setSubject(java.lang.String subject) throws java.io.IOException, PD4InvalidPasswordException
subject
- a value to override document "Subject" string. Implicitly invokes read()
if has not been triggered before.
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)
.public void setModDate() throws java.io.IOException, PD4InvalidPasswordException
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)
.public java.lang.String getModDate() throws java.io.IOException, PD4InvalidPasswordException
read()
if has not been triggered before.
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)
.public void read() throws java.io.IOException, PD4InvokeException, PD4InvalidPasswordException
java.io.IOException
- read/parsing errors
PD4InvokeException
- PDF parsing specific errors
PD4InvalidPasswordException
protected abstract void read(int objectCounter) throws java.io.IOException, PD4InvalidPasswordException
objectCounter
- initial object number to re-index PDF objects. Used by PDF merge scenarios
java.io.IOException
- read/parsing errors
PD4InvalidPasswordException
protected int getObjectCounter()
public java.lang.String getPageContent(int pageIndex) throws PD4InvalidPasswordException, java.io.IOException
PD4InvalidPasswordException
java.io.IOException
public int deletePage(int pageNumber) throws PD4InvalidPasswordException, java.io.IOException
pageNumber
- index of page to delete (first page is 1)
PD4InvalidPasswordException
java.io.IOException
public static boolean[] computeScope(java.lang.String scope, int pageNum)
scope
- "null" = all pages. Allowed syntax: "1", "3-5", "2+", "last", "even", "odd", "1+,skiplast", "5+,even"pageNum
- number of pages
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |