com.lowagie.text.pdf
public class PdfCopy extends PdfWriter
| Nested Class Summary | |
|---|---|
| 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 |
| 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 |
| boolean | rotateContents Holds value of property rotateContents. |
| Constructor Summary | |
|---|---|
| PdfCopy(Document document, OutputStream os)
Constructor | |
| Method Summary | |
|---|---|
| PdfIndirectReference | add(PdfOutline outline) |
| PdfIndirectReference | add(PdfPage page, PdfContents contents) |
| void | addAnnotation(PdfAnnotation annot) |
| void | addFieldResources(PdfDictionary catalog) |
| void | addPage(PdfImportedPage iPage)
Add an imported page to our output |
| 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) |
| 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. |
Parameters: document os outputstream
Parameters: iPage an imported page
Throws: IOException, BadPdfFormatException
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.
Parameters: reader The reader of the input file that is being copied
Throws: IOException, BadPdfFormatException
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);
Parameters: iPage an imported page
Returns: the PageStamp
Parameters: reader the reader of the document pageNumber which page to get
Returns: the page
Returns: Value of property rotateContents.
Parameters: rotateContents New value of property rotateContents.