Class PdfCopy
- Namespace
- iTextSharp.text.pdf
- Assembly
- iTextSharp.LGPLv2.Core.dll
Make copies of PDF documents. Documents can be edited after reading and before writing them out. @author Mark Thompson
public class PdfCopy : PdfWriter, IDocListener, IElementListener, IDisposable, IPdfViewerPreferences, IPdfEncryptionSettings, IPdfVersion, IPdfDocumentActions, IPdfPageActions, IPdfXConformance, IPdfRunDirection, IPdfAnnotations
- Inheritance
-
PdfCopy
- Implements
- Derived
- Inherited Members
Constructors
PdfCopy(Document, Stream)
Constructor
public PdfCopy(Document document, Stream os)
Parameters
Fields
CurrentObjectNum
protected int CurrentObjectNum
Field Value
FieldArray
protected PdfArray FieldArray
Field Value
FieldTemplates
protected INullValueDictionary<PdfTemplate, object> FieldTemplates
Field Value
IndirectMap
protected INullValueDictionary<PdfReader, INullValueDictionary<PdfCopy.RefKey, PdfCopy.IndirectReferences>> IndirectMap
Field Value
Indirects
protected INullValueDictionary<PdfCopy.RefKey, PdfCopy.IndirectReferences> Indirects
Field Value
NamePtr
protected int[] NamePtr
Field Value
- int[]
Reader
protected PdfReader Reader
Field Value
acroForm
protected PdfIndirectReference acroForm
Field Value
Properties
RotateContents
Checks if the content is automatically adjusted to compensate the original page rotation.
public bool RotateContents { get; set; }
Property Value
- bool
the auto-rotation status
Methods
AddAnnotation(PdfAnnotation)
public override void AddAnnotation(PdfAnnotation annot)
Parameters
annot
PdfAnnotation
AddPage(Rectangle, int)
Adds a blank page. @since 2.1.5
public void AddPage(Rectangle rect, int rotation)
Parameters
AddPage(PdfImportedPage)
Add an imported page to our output @throws IOException, BadPdfFormatException
public void AddPage(PdfImportedPage iPage)
Parameters
iPage
PdfImportedPagean imported page
Close()
Signals that the 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 referencetable is composed and everything is written to the outputstream embedded in a Trailer.
public override void Close()
CopyAcroForm(PdfReader)
Copy the acroform for an input document. Note that you can only have one, we make no effort to merge them. @throws IOException, BadPdfFormatException
public void CopyAcroForm(PdfReader reader)
Parameters
reader
PdfReaderThe reader of the input file that is being copied
CopyArray(PdfArray)
Translate a PRArray to a PdfArray. Also translate all of the objects contained in it
protected PdfArray CopyArray(PdfArray inp)
Parameters
inp
PdfArray
Returns
CopyDictionary(PdfDictionary)
Translate a PRDictionary to a PdfDictionary. Also translate all of the objects contained in it.
protected PdfDictionary CopyDictionary(PdfDictionary inp)
Parameters
inp
PdfDictionary
Returns
CopyIndirect(PrIndirectReference)
Translate a PRIndirectReference to a PdfIndirectReference In addition, translates the object numbers, and copies the referenced object to the output file. NB: PRIndirectReferences (and PRIndirectObjects) really need to know what file they came from, because each file has its own namespace. The translation we do from their namespace to ours is at best heuristic, and guaranteed to fail under some circumstances.
protected virtual PdfIndirectReference CopyIndirect(PrIndirectReference inp)
Parameters
Returns
CopyObject(PdfObject)
Translate a PR-object to a Pdf-object
protected PdfObject CopyObject(PdfObject inp)
Parameters
inp
PdfObject
Returns
CopyStream(PrStream)
Translate a PRStream to a PdfStream. The data part copies itself.
protected PdfStream CopyStream(PrStream inp)
Parameters
inp
PrStream
Returns
CreatePageStamp(PdfImportedPage)
Create a page stamp. New content and annotations, including new fields, are allowed. The fields added cannot have parents in another pages. This method modifies the PdfReader instance. 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);
public PdfCopy.PageStamp CreatePageStamp(PdfImportedPage iPage)
Parameters
iPage
PdfImportedPagean imported page
Returns
FreeReader(PdfReader)
public override void FreeReader(PdfReader reader)
Parameters
reader
PdfReader
GetCatalog(PdfIndirectReference)
the getCatalog method is part of PdfWriter. we wrap this so that we can extend it
protected override PdfDictionary GetCatalog(PdfIndirectReference rootObj)
Parameters
rootObj
PdfIndirectReference
Returns
GetImportedPage(PdfReader, int)
Grabs a page from the input document
public override PdfImportedPage GetImportedPage(PdfReader reader, int pageNumber)
Parameters
Returns
- PdfImportedPage
the page
SetFromIPage(PdfImportedPage)
convenience method. Given an importedpage, set our "globals"
protected int SetFromIPage(PdfImportedPage iPage)
Parameters
iPage
PdfImportedPage
Returns
SetFromReader(PdfReader)
convenience method. Given a reader, set our "globals"
protected void SetFromReader(PdfReader reader)
Parameters
reader
PdfReader