示例#1
0
 internal PdfImportedPage(PdfReaderInstance readerInstance, PdfWriter writer, int pageNumber) {
     this.readerInstance = readerInstance;
     this.pageNumber = pageNumber;
     this.writer = writer;
     bBox = readerInstance.Reader.GetPageSize(pageNumber);
     SetMatrix(1, 0, 0, 1, -bBox.Left, -bBox.Bottom);
     type = TYPE_IMPORTED;
 }
示例#2
0
 internal PdfImportedPage(PdfReaderInstance readerInstance, PdfWriter writer, int pageNumber)
 {
     this.readerInstance = readerInstance;
     this.pageNumber     = pageNumber;
     thisReference       = writer.PdfIndirectReference;
     bBox = readerInstance.Reader.getPageSize(pageNumber);
     type = TYPE_IMPORTED;
 }
示例#3
0
        /**
         * convenience method. Given an importedpage, set our "globals"
         */
        protected int SetFromIPage(PdfImportedPage iPage)
        {
            int pageNum            = iPage.PageNumber;
            PdfReaderInstance inst = currentPdfReaderInstance = iPage.PdfReaderInstance;

            reader = inst.Reader;
            SetFromReader(reader);
            return(pageNum);
        }
 internal PdfImportedPage(PdfReaderInstance readerInstance, PdfWriter writer, int pageNumber)
 {
     this.readerInstance = readerInstance;
     this.pageNumber     = pageNumber;
     this.writer         = writer;
     bBox = readerInstance.Reader.GetPageSize(pageNumber);
     SetMatrix(1, 0, 0, 1, -bBox.Left, -bBox.Bottom);
     type = TYPE_IMPORTED;
 }
示例#5
0
        /**
         * Signals that the <CODE>Document</CODE> was closed and that no other
         * <CODE>Elements</CODE> will be added.
         * <P>
         * 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()
        {
            if (open)
            {
                PdfReaderInstance ri = currentPdfReaderInstance;
                pdf.Close();
                base.Close();
                if (ri != null)
                {
                    try {
                        ri.Reader.Close();
                        ri.ReaderFile.Close();
                    }
                    catch (IOException) {
                        // empty on purpose
                    }
                }
            }
        }
示例#6
0
        /**
         * Signals that the <CODE>Document</CODE> was closed and that no other
         * <CODE>Elements</CODE> will be added.
         * <P>
         * 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()
        {
            if (open)
            {
                PdfReaderInstance ri = currentPdfReaderInstance;
                pdf.Close();
                base.Close();
                // Users are responsible for closing PdfReaders
                //if (ri != null) {
                //    try {
                //        ri.Reader.Close();
                //        ri.ReaderFile.Close();
                //    }
                //    catch (IOException) {
                //        // empty on purpose
                //    }
                //}
            }
        }
示例#7
0
 protected internal virtual int GetNewObjectNumber(PdfReader reader, int number, int generation) {
     if (currentPdfReaderInstance == null) {
 	    currentPdfReaderInstance = GetPdfReaderInstance(reader);
     }
     return currentPdfReaderInstance.GetNewObjectNumber(number, generation);
 }
示例#8
0
        protected void AddSharedObjectsToBody()
        {
            // add the fonts
            foreach (FontDetails details in documentFonts.Values) {
                details.WriteFont(this);
            }
            // add the form XObjects
            foreach (Object[] objs in formXObjects.Values) {
                PdfTemplate template = (PdfTemplate)objs[1];
                if (template != null && template.IndirectReference is PRIndirectReference)
                    continue;
                if (template != null && template.Type == PdfTemplate.TYPE_TEMPLATE) {
                    AddToBody(template.GetFormXObject(compressionLevel), template.IndirectReference);
                }
            }
            // add all the dependencies in the imported pages
            foreach (PdfReaderInstance rd in readerInstances.Values) {
                currentPdfReaderInstance = rd;
                currentPdfReaderInstance.WriteAllPages();
            }
            currentPdfReaderInstance = null;
            // add the color
            foreach (ColorDetails color in documentColors.Values) {
                AddToBody(color.GetSpotColor(this), color.IndirectReference);
            }
            // add the pattern
            foreach (PdfPatternPainter pat in documentPatterns.Keys) {
                AddToBody(pat.GetPattern(compressionLevel), pat.IndirectReference);
            }
            // add the shading patterns
            foreach (PdfShadingPattern shadingPattern in documentShadingPatterns.Keys) {
                shadingPattern.AddToBody();
            }
            // add the shadings
            foreach (PdfShading shading in documentShadings.Keys) {
                shading.AddToBody();
            }
            // add the extgstate
            foreach (KeyValuePair<PdfDictionary, PdfObject[]> entry in documentExtGState) {
                PdfDictionary gstate = entry.Key;
                PdfObject[] obj = entry.Value;
                AddToBody(gstate, (PdfIndirectReference)obj[1]);
            }

            // add the properties
            foreach (KeyValuePair<Object, PdfObject[]> entry in documentProperties) {
                Object prop = entry.Key;
                PdfObject[] obj = entry.Value;
                if (prop is PdfLayerMembership){
                    PdfLayerMembership layer = (PdfLayerMembership)prop;
                    AddToBody(layer.PdfObject, layer.Ref);
                }
                else if ((prop is PdfDictionary) && !(prop is PdfLayer)){
                    AddToBody((PdfDictionary)prop, (PdfIndirectReference)obj[1]);
                }
            }
        }
示例#9
0
 /** Writes the reader to the document and frees the memory used by it.
 * The main use is when concatenating multiple documents to keep the
 * memory usage restricted to the current appending document.
 * @param reader the <CODE>PdfReader</CODE> to free
 * @throws IOException on error
 */
 public virtual void FreeReader(PdfReader reader)
 {
     readerInstances.TryGetValue(reader, out currentPdfReaderInstance);
     if (currentPdfReaderInstance == null)
         return;
     currentPdfReaderInstance.WriteAllPages();
     currentPdfReaderInstance = null;
     readerInstances.Remove(reader);
 }
示例#10
0
 /** Writes the reader to the document and frees the memory used by it.
 * The main use is when concatenating multiple documents to keep the
 * memory usage restricted to the current appending document.
 * @param reader the <CODE>PdfReader</CODE> to free
 * @throws IOException on error
 */
 public virtual void FreeReader(PdfReader reader)
 {
     currentPdfReaderInstance = (PdfReaderInstance)importedPages[reader];
     if (currentPdfReaderInstance == null)
         return;
     currentPdfReaderInstance.WriteAllPages();
     currentPdfReaderInstance = null;
     importedPages.Remove(reader);
 }
示例#11
0
 internal virtual RandomAccessFileOrArray GetReaderFile(PdfReader reader) {
     if (currentPdfReaderInstance == null) {
 	    currentPdfReaderInstance = GetPdfReaderInstance(reader);
     }
     return currentPdfReaderInstance.ReaderFile;
 }