Save This Page
Home » iText-2.1.7 » com.lowagie » text » pdf » [javadoc | source]
com.lowagie.text.pdf
public class: PdfCopy [javadoc | source]
java.lang.Object
   com.lowagie.text.DocWriter
      com.lowagie.text.pdf.PdfWriter
         com.lowagie.text.pdf.PdfCopy

All Implemented Interfaces:
    PdfPageActions, PdfRunDirection, PdfViewerPreferences, PdfDocumentActions, PdfAnnotations, PdfXConformance, PdfEncryptionSettings, PdfVersion, DocListener

Direct Known Subclasses:
    PdfSmartCopy

Make copies of PDF documents. Documents can be edited after reading and before writing them out.
Nested Class Summary:
static class  PdfCopy.IndirectReferences  This class holds information about indirect references, since they are renumbered by iText. 
protected static class  PdfCopy.RefKey  A key to allow us to hash indirect references 
public static class  PdfCopy.PageStamp   
public static class  PdfCopy.StampContent   
Field Summary
protected  HashMap indirects     
protected  HashMap indirectMap     
protected  int currentObjectNum     
protected  PdfReader reader     
protected  PdfIndirectReference acroForm     
protected  int[] namePtr     
protected  PdfArray fieldArray     
protected  HashMap fieldTemplates     
Fields inherited from com.lowagie.text.pdf.PdfWriter:
GENERATION_MAX,  pdf,  directContent,  directContentUnder,  body,  extraCatalog,  root,  pageReferences,  currentPageNumber,  tabs,  prevxref,  newBookmarks,  VERSION_1_2,  VERSION_1_3,  VERSION_1_4,  VERSION_1_5,  VERSION_1_6,  VERSION_1_7,  PDF_VERSION_1_2,  PDF_VERSION_1_3,  PDF_VERSION_1_4,  PDF_VERSION_1_5,  PDF_VERSION_1_6,  PDF_VERSION_1_7,  pdf_version,  PageLayoutSinglePage,  PageLayoutOneColumn,  PageLayoutTwoColumnLeft,  PageLayoutTwoColumnRight,  PageLayoutTwoPageLeft,  PageLayoutTwoPageRight,  PageModeUseNone,  PageModeUseOutlines,  PageModeUseThumbs,  PageModeFullScreen,  PageModeUseOC,  PageModeUseAttachments,  HideToolbar,  HideMenubar,  HideWindowUI,  FitWindow,  CenterWindow,  DisplayDocTitle,  NonFullScreenPageModeUseNone,  NonFullScreenPageModeUseOutlines,  NonFullScreenPageModeUseThumbs,  NonFullScreenPageModeUseOC,  DirectionL2R,  DirectionR2L,  PrintScalingNone,  DOCUMENT_CLOSE,  WILL_SAVE,  DID_SAVE,  WILL_PRINT,  DID_PRINT,  SIGNATURE_EXISTS,  SIGNATURE_APPEND_ONLY,  xmpMetadata,  PDFXNONE,  PDFX1A2001,  PDFX32002,  PDFA1A,  PDFA1B,  STANDARD_ENCRYPTION_40,  STANDARD_ENCRYPTION_128,  ENCRYPTION_AES_128,  ENCRYPTION_MASK,  DO_NOT_ENCRYPT_METADATA,  EMBEDDED_FILES_ONLY,  ALLOW_PRINTING,  ALLOW_MODIFY_CONTENTS,  ALLOW_COPY,  ALLOW_MODIFY_ANNOTATIONS,  ALLOW_FILL_IN,  ALLOW_SCREENREADERS,  ALLOW_ASSEMBLY,  ALLOW_DEGRADED_PRINTING,  AllowPrinting,  AllowModifyContents,  AllowCopy,  AllowModifyAnnotations,  AllowFillIn,  AllowScreenReaders,  AllowAssembly,  AllowDegradedPrinting,  STRENGTH40BITS,  STRENGTH128BITS,  crypto,  fullCompression,  compressionLevel,  documentFonts,  fontNumber,  formXObjects,  formXObjectsCounter,  importedPages,  currentPdfReaderInstance,  documentColors,  colorNumber,  documentPatterns,  patternNumber,  documentShadingPatterns,  documentShadings,  documentExtGState,  documentProperties,  tagged,  structureTreeRoot,  documentOCG,  documentOCGorder,  OCProperties,  OCGRadioGroup,  OCGLocked,  PAGE_OPEN,  PAGE_CLOSE,  group,  SPACE_CHAR_RATIO_DEFAULT,  NO_SPACE_CHAR_RATIO,  RUN_DIRECTION_DEFAULT,  RUN_DIRECTION_NO_BIDI,  RUN_DIRECTION_LTR,  RUN_DIRECTION_RTL,  runDirection,  userunit,  defaultColorspace,  documentSpotPatterns,  patternColorspaceRGB,  patternColorspaceGRAY,  patternColorspaceCMYK,  imageDictionary,  JBIG2Globals
Fields inherited from com.lowagie.text.DocWriter:
NEWLINE,  TAB,  LT,  SPACE,  EQUALS,  QUOTE,  GT,  FORWARD,  pageSize,  document,  os,  open,  pause,  closeStream
Constructor:
 public PdfCopy(Document document,
    OutputStream os) throws DocumentException 
    Constructor
    Parameters:
    document -
    os - outputstream
Method from com.lowagie.text.pdf.PdfCopy Summary:
add,   add,   addAnnotation,   addPage,   addPage,   close,   copyAcroForm,   copyArray,   copyDictionary,   copyIndirect,   copyObject,   copyStream,   createPageStamp,   freeReader,   getCatalog,   getImportedPage,   isRotateContents,   setFromIPage,   setFromReader,   setRotateContents
Methods from com.lowagie.text.pdf.PdfWriter:
add,   add,   add,   addAnnotation,   addAnnotation,   addCalculationOrder,   addDeveloperExtension,   addDirectImageSimple,   addDirectImageSimple,   addDirectTemplateSimple,   addFileAttachment,   addFileAttachment,   addFileAttachment,   addJavaScript,   addJavaScript,   addJavaScript,   addJavaScript,   addJavaScript,   addJavaScript,   addLocalDestinations,   addOCGRadioGroup,   addSharedObjectsToBody,   addSimple,   addSimple,   addSimpleExtGState,   addSimplePattern,   addSimplePatternColorspace,   addSimpleProperty,   addSimpleShading,   addSimpleShadingPattern,   addToBody,   addToBody,   addToBody,   addToBody,   addToBody,   addToBody,   addViewerPreference,   clearTextWrap,   close,   createXmpMetadata,   eliminateFontSubset,   fillOCProperties,   fitsPage,   fitsPage,   freeReader,   getAcroForm,   getBoxSize,   getCatalog,   getColorspaceName,   getCompressionLevel,   getCurrentDocumentSize,   getCurrentPage,   getCurrentPageNumber,   getDefaultColorspace,   getDirectContent,   getDirectContentUnder,   getEncryption,   getExtraCatalog,   getGroup,   getImageReference,   getImportedPage,   getIndirectReferenceNumber,   getInfo,   getInstance,   getInstance,   getNewObjectNumber,   getOCProperties,   getOs,   getPDFXConformance,   getPageEvent,   getPageNumber,   getPageReference,   getPageSize,   getPdfDocument,   getPdfIndirectReference,   getPdfVersion,   getReaderFile,   getReferenceJBIG2Globals,   getRootOutline,   getRunDirection,   getSpaceCharRatio,   getStructureTreeRoot,   getTabs,   getUserunit,   getVerticalPosition,   isFullCompression,   isPdfX,   isRgbTransparencyBlending,   isStrictImageSequence,   isTagged,   isUserProperties,   lockLayer,   open,   propertyExists,   registerLayer,   releaseTemplate,   reorderPages,   resetContent,   setAdditionalAction,   setAtLeastPdfVersion,   setBoxSize,   setCollection,   setCompressionLevel,   setCropBoxSize,   setDefaultColorspace,   setDuration,   setEncryption,   setEncryption,   setEncryption,   setEncryption,   setEncryption,   setFullCompression,   setGroup,   setInitialLeading,   setLinearPageMode,   setOpenAction,   setOpenAction,   setOutlines,   setOutputIntents,   setOutputIntents,   setOutputIntents,   setPDFXConformance,   setPageAction,   setPageEmpty,   setPageEvent,   setPageLabels,   setPageXmpMetadata,   setPdfVersion,   setPdfVersion,   setRgbTransparencyBlending,   setRunDirection,   setSigFlags,   setSpaceCharRatio,   setStrictImageSequence,   setTabs,   setTagged,   setThumbnail,   setTransition,   setUserProperties,   setUserunit,   setViewerPreferences,   setXmpMetadata,   writeOutlines
Methods from com.lowagie.text.DocWriter:
add,   addTabs,   close,   flush,   getISOBytes,   isCloseStream,   isPaused,   newPage,   open,   pause,   resetFooter,   resetHeader,   resetPageCount,   resume,   setCloseStream,   setFooter,   setHeader,   setMarginMirroring,   setMarginMirroringTopBottom,   setMargins,   setPageCount,   setPageSize,   write,   write,   writeEnd,   writeEnd,   writeMarkupAttributes,   writeStart
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from com.lowagie.text.pdf.PdfCopy Detail:
 public PdfIndirectReference add(PdfOutline outline) 
 PdfIndirectReference add(PdfPage page,
    PdfContents contents) throws PdfException 
 public  void addAnnotation(PdfAnnotation annot) 
 public  void addPage(PdfImportedPage iPage) throws IOException, BadPdfFormatException 
    Add an imported page to our output
 public  void addPage(Rectangle rect,
    int rotation) 
    Adds a blank page.
 public  void 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 reference table is composed and everything is written to the outputstream embedded in a Trailer.

 public  void copyAcroForm(PdfReader reader) throws IOException, BadPdfFormatException 
    Copy the acroform for an input document. Note that you can only have one, we make no effort to merge them.
 protected PdfArray copyArray(PdfArray in) throws IOException, BadPdfFormatException 
    Translate a PRArray to a PdfArray. Also translate all of the objects contained in it
 protected PdfDictionary copyDictionary(PdfDictionary in) throws IOException, BadPdfFormatException 
    Translate a PRDictionary to a PdfDictionary. Also translate all of the objects contained in it.
 protected PdfIndirectReference copyIndirect(PRIndirectReference in) throws IOException, BadPdfFormatException 
    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 PdfObject copyObject(PdfObject in) throws IOException, BadPdfFormatException 
    Translate a PR-object to a Pdf-object
 protected PdfStream copyStream(PRStream in) throws IOException, BadPdfFormatException 
    Translate a PRStream to a PdfStream. The data part copies itself.
 public PageStamp createPageStamp(PdfImportedPage iPage) 
    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  void freeReader(PdfReader reader) throws IOException 
 protected PdfDictionary getCatalog(PdfIndirectReference rootObj) 
 public PdfImportedPage getImportedPage(PdfReader reader,
    int pageNumber) 
    Grabs a page from the input document
 public boolean isRotateContents() 
    Getter for property rotateContents.
 protected int setFromIPage(PdfImportedPage iPage) 
    convenience method. Given an imported page, set our "globals"
 protected  void setFromReader(PdfReader reader) 
    convenience method. Given a reader, set our "globals"
 public  void setRotateContents(boolean rotateContents) 
    Setter for property rotateContents.