|
![]() |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.lowagie.text.DocWriter
com.lowagie.text.pdf.PdfWriter
com.lowagie.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 | |
---|---|
(package private) static class |
PdfCopy.IndirectReferences
This class holds information about indirect references, since they are renumbered by iText. |
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.lowagie.text.pdf.PdfWriter |
---|
PdfWriter.PdfBody, PdfWriter.PdfTrailer |
Field Summary | |
---|---|
protected PdfIndirectReference |
acroForm
|
protected int |
currentObjectNum
|
protected PdfArray |
fieldArray
|
protected HashMap |
fieldTemplates
|
protected HashMap |
indirectMap
|
protected HashMap |
indirects
|
protected int[] |
namePtr
|
protected PdfReader |
reader
|
private boolean |
rotateContents
Holds value of property rotateContents. |
Fields inherited from class com.lowagie.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)
|
(package private) PdfIndirectReference |
add(PdfPage page,
PdfContents contents)
Adds some PdfContents to this Writer. |
void |
addAnnotation(PdfAnnotation annot)
Use this methods to add a PdfAnnotation or a PdfFormField
to the document. |
private void |
addFieldResources(PdfDictionary catalog)
|
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.lowagie.text.DocWriter |
---|
add, addTabs, flush, getISOBytes, isCloseStream, isPaused, newPage, pause, resetFooter, resetHeader, resetPageCount, resume, setCloseStream, setFooter, setHeader, 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 indirects
protected HashMap indirectMap
protected int currentObjectNum
protected PdfReader reader
protected PdfIndirectReference acroForm
protected int[] namePtr
private boolean rotateContents
protected PdfArray fieldArray
protected HashMap 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
private void addFieldResources(PdfDictionary catalog) throws IOException
IOException
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.lowagie.text.pdf.PdfAnnotation)
PdfIndirectReference add(PdfPage page, PdfContents contents) throws PdfException
PdfWriter
PdfContents
to this Writer.
The document has to be open before you can begin to add content to the body of the document.
add
in class PdfWriter
page
- the PdfPage
to addcontents
- the PdfContents
of the page
PdfIndirectReference
PdfException
- on errorpublic 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
|
Hosted by Hostbasket | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |