|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.itextpdf.text.DocWriter
com.itextpdf.text.pdf.PdfWriter
com.itextpdf.text.pdf.PdfCopy
public class PdfCopy
Make copies of PDF documents. Documents can be edited after reading and before writing them out.
Nested Class Summary | |
---|---|
static class |
PdfCopy.PageStamp
|
protected static class |
PdfCopy.RefKey
A key to allow us to hash indirect references |
static class |
PdfCopy.StampContent
|
Nested classes/interfaces inherited from class com.itextpdf.text.pdf.PdfWriter |
---|
PdfWriter.PdfBody |
Field Summary | |
---|---|
protected PdfIndirectReference |
acroForm
|
protected int |
currentObjectNum
|
protected PdfArray |
fieldArray
|
protected HashSet<PdfTemplate> |
fieldTemplates
|
protected HashMap<PdfReader,HashMap<PdfCopy.RefKey,com.itextpdf.text.pdf.PdfCopy.IndirectReferences>> |
indirectMap
|
protected HashMap<PdfCopy.RefKey,com.itextpdf.text.pdf.PdfCopy.IndirectReferences> |
indirects
|
protected int[] |
namePtr
|
protected PdfReader |
reader
|
Fields inherited from class com.itextpdf.text.DocWriter |
---|
closeStream, document, EQUALS, FORWARD, GT, LT, NEWLINE, open, os, pageSize, pause, QUOTE, SPACE, TAB |
Constructor Summary | |
---|---|
PdfCopy(Document document,
OutputStream os)
Constructor |
Method Summary | |
---|---|
PdfIndirectReference |
add(PdfOutline outline)
|
void |
addAnnotation(PdfAnnotation annot)
Use this methods to add a PdfAnnotation or a PdfFormField
to the document. |
void |
addPage(PdfImportedPage iPage)
Add an imported page to our output |
void |
addPage(Rectangle rect,
int rotation)
Adds a blank page. |
void |
close()
Signals that the Document was closed and that no other
Elements will be added. |
void |
copyAcroForm(PdfReader reader)
Copy the acroform for an input document. |
protected PdfArray |
copyArray(PdfArray in)
Translate a PRArray to a PdfArray. |
protected PdfDictionary |
copyDictionary(PdfDictionary in)
Translate a PRDictionary to a PdfDictionary. |
protected PdfIndirectReference |
copyIndirect(PRIndirectReference in)
Translate a PRIndirectReference to a PdfIndirectReference In addition, translates the object numbers, and copies the referenced object to the output file. |
protected PdfObject |
copyObject(PdfObject in)
Translate a PR-object to a Pdf-object |
protected PdfStream |
copyStream(PRStream in)
Translate a PRStream to a PdfStream. |
PdfCopy.PageStamp |
createPageStamp(PdfImportedPage iPage)
Create a page stamp. |
void |
freeReader(PdfReader reader)
Use this method to writes the reader to the document and free the memory used by it. |
protected PdfDictionary |
getCatalog(PdfIndirectReference rootObj)
|
PdfImportedPage |
getImportedPage(PdfReader reader,
int pageNumber)
Grabs a page from the input document |
boolean |
isRotateContents()
Getter for property rotateContents. |
protected int |
setFromIPage(PdfImportedPage iPage)
convenience method. |
protected void |
setFromReader(PdfReader reader)
convenience method. |
void |
setRotateContents(boolean rotateContents)
Setter for property rotateContents. |
Methods inherited from class com.itextpdf.text.DocWriter |
---|
add, addTabs, flush, getISOBytes, isCloseStream, isPaused, newPage, pause, resetPageCount, resume, setCloseStream, setMarginMirroring, setMarginMirroringTopBottom, setMargins, setPageCount, setPageSize, write, write, writeEnd, writeEnd, writeMarkupAttributes, writeStart |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected HashMap<PdfCopy.RefKey,com.itextpdf.text.pdf.PdfCopy.IndirectReferences> indirects
protected HashMap<PdfReader,HashMap<PdfCopy.RefKey,com.itextpdf.text.pdf.PdfCopy.IndirectReferences>> indirectMap
protected int currentObjectNum
protected PdfReader reader
protected PdfIndirectReference acroForm
protected int[] namePtr
protected PdfArray fieldArray
protected HashSet<PdfTemplate> fieldTemplates
Constructor Detail |
---|
public PdfCopy(Document document, OutputStream os) throws DocumentException
document
- os
- outputstream
DocumentException
Method Detail |
---|
public boolean isRotateContents()
public void setRotateContents(boolean rotateContents)
rotateContents
- New value of property rotateContents.public PdfImportedPage getImportedPage(PdfReader reader, int pageNumber)
getImportedPage
in class PdfWriter
reader
- the reader of the documentpageNumber
- which page to get
protected PdfIndirectReference copyIndirect(PRIndirectReference in) throws IOException, BadPdfFormatException
IOException
BadPdfFormatException
protected PdfDictionary copyDictionary(PdfDictionary in) throws IOException, BadPdfFormatException
IOException
BadPdfFormatException
protected PdfStream copyStream(PRStream in) throws IOException, BadPdfFormatException
IOException
BadPdfFormatException
protected PdfArray copyArray(PdfArray in) throws IOException, BadPdfFormatException
IOException
BadPdfFormatException
protected PdfObject copyObject(PdfObject in) throws IOException, BadPdfFormatException
IOException
BadPdfFormatException
protected int setFromIPage(PdfImportedPage iPage)
protected void setFromReader(PdfReader reader)
public void addPage(PdfImportedPage iPage) throws IOException, BadPdfFormatException
iPage
- an imported page
IOException,
- BadPdfFormatException
IOException
BadPdfFormatException
public void addPage(Rectangle rect, int rotation)
rect
- The page dimensionrotation
- The rotation angle in degreespublic void copyAcroForm(PdfReader reader) throws IOException, BadPdfFormatException
reader
- The reader of the input file that is being copied
IOException,
- BadPdfFormatException
IOException
BadPdfFormatException
protected PdfDictionary getCatalog(PdfIndirectReference rootObj)
getCatalog
in class PdfWriter
public void close()
Document
was closed and that no other
Elements
will be added.
The pages-tree is built and written to the outputstream. A Catalog is constructed, as well as an Info-object, the reference table is composed and everything is written to the outputstream embedded in a Trailer.
close
in interface DocListener
close
in class PdfWriter
DocWriter.close()
public PdfIndirectReference add(PdfOutline outline)
public void addAnnotation(PdfAnnotation annot)
PdfAnnotations
PdfAnnotation
or a PdfFormField
to the document. Only the top parent of a PdfFormField
needs to be added.
addAnnotation
in interface PdfAnnotations
addAnnotation
in class PdfWriter
annot
- the PdfAnnotation
or the PdfFormField
to addPdfAnnotations.addAnnotation(com.itextpdf.text.pdf.PdfAnnotation)
public void freeReader(PdfReader reader) throws IOException
PdfWriter
freeReader
in class PdfWriter
reader
- the PdfReader
to free
IOException
- on errorpublic PdfCopy.PageStamp createPageStamp(PdfImportedPage iPage)
The general usage to stamp something in a page is:
PdfImportedPage page = copy.getImportedPage(reader, 1); PdfCopy.PageStamp ps = copy.createPageStamp(page); ps.addAnnotation(PdfAnnotation.createText(copy, new Rectangle(50, 180, 70, 200), "Hello", "No Thanks", true, "Comment")); PdfContentByte under = ps.getUnderContent(); under.addImage(img); PdfContentByte over = ps.getOverContent(); over.beginText(); over.setFontAndSize(bf, 18); over.setTextMatrix(30, 30); over.showText("total page " + totalPage); over.endText(); ps.alterContents(); copy.addPage(page);
iPage
- an imported page
PageStamp
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |