/** * Adds some <CODE>PdfContents</CODE> to this Writer. * <P> * The document has to be open before you can begin to add content * to the body of the document. * * @return a <CODE>PdfIndirectReference</CODE> * @param page the <CODE>PdfPage</CODE> to add * @param contents the <CODE>PdfContents</CODE> of the page * @throws PdfException on error */ internal virtual PdfIndirectReference Add(PdfPage page, PdfContents contents) { if (!open) { throw new PdfException("The document isn't open."); } PdfIndirectObject objecta; objecta = AddToBody(contents); page.Add(objecta.IndirectReference); if (group != null) { page.Put(PdfName.GROUP, group); group = null; } else if (rgbTransparencyBlending) { PdfDictionary pp = new PdfDictionary(); pp.Put(PdfName.TYPE, PdfName.GROUP); pp.Put(PdfName.S, PdfName.TRANSPARENCY); pp.Put(PdfName.CS, PdfName.DEVICERGB); page.Put(PdfName.GROUP, pp); } root.AddPage(page); currentPageNumber++; return null; }
internal override PdfIndirectReference Add(PdfPage page, PdfContents contents) { return null; }
internal override PdfIndirectReference Add(PdfPage page, PdfContents contents) { return(null); }
/** * Adds a blank page. * @param rect The page dimension * @param rotation The rotation angle in degrees * @since 2.1.5 */ public void AddPage(Rectangle rect, int rotation) { PdfRectangle mediabox = new PdfRectangle(rect, rotation); PageResources resources = new PageResources(); PdfPage page = new PdfPage(mediabox, new Hashtable(), resources.Resources, 0); page.Put(PdfName.TABS, Tabs); root.AddPage(page); ++currentPageNumber; }
/** * Makes a new page and sends it to the <CODE>PdfWriter</CODE>. * * @return a <CODE>bool</CODE> * @throws DocumentException on error */ public override bool NewPage() { lastElementType = -1; if (writer == null || (writer.DirectContent.Size == 0 && writer.DirectContentUnder.Size == 0 && (pageEmpty || writer.IsPaused()))) { SetNewPageSizeAndMargins(); return false; } if (!open || close) { throw new Exception("The document isn't open."); } IPdfPageEvent pageEvent = writer.PageEvent; if (pageEvent != null) pageEvent.OnEndPage(writer, this); //Added to inform any listeners that we are moving to a new page (added by David Freels) base.NewPage(); // the following 2 lines were added by Pelikan Stephan indentation.imageIndentLeft = 0; indentation.imageIndentRight = 0; // we flush the arraylist with recently written lines FlushLines(); // we prepare the elements of the page dictionary // [U1] page size and rotation int rotation = pageSize.Rotation; // [C10] if (writer.IsPdfX()) { if (thisBoxSize.ContainsKey("art") && thisBoxSize.ContainsKey("trim")) throw new PdfXConformanceException("Only one of ArtBox or TrimBox can exist in the page."); if (!thisBoxSize.ContainsKey("art") && !thisBoxSize.ContainsKey("trim")) { if (thisBoxSize.ContainsKey("crop")) thisBoxSize["trim"] = thisBoxSize["crop"]; else thisBoxSize["trim"] = new PdfRectangle(pageSize, pageSize.Rotation); } } // [M1] pageResources.AddDefaultColorDiff(writer.DefaultColorspace); if (writer.RgbTransparencyBlending) { PdfDictionary dcs = new PdfDictionary(); dcs.Put(PdfName.CS, PdfName.DEVICERGB); pageResources.AddDefaultColorDiff(dcs); } PdfDictionary resources = pageResources.Resources; // we create the page dictionary PdfPage page = new PdfPage(new PdfRectangle(pageSize, rotation), thisBoxSize, resources, rotation); page.Put(PdfName.TABS, writer.Tabs); // we complete the page dictionary // [C9] if there is XMP data to add: add it if (xmpMetadata != null) { PdfStream xmp = new PdfStream(xmpMetadata); xmp.Put(PdfName.TYPE, PdfName.METADATA); xmp.Put(PdfName.SUBTYPE, PdfName.XML); PdfEncryption crypto = writer.Encryption; if (crypto != null && !crypto.IsMetadataEncrypted()) { PdfArray ar = new PdfArray(); ar.Add(PdfName.CRYPT); xmp.Put(PdfName.FILTER, ar); } page.Put(PdfName.METADATA, writer.AddToBody(xmp).IndirectReference); } // [U3] page actions: transition, duration, additional actions if (this.transition!=null) { page.Put(PdfName.TRANS, this.transition.TransitionDictionary); transition = null; } if (this.duration>0) { page.Put(PdfName.DUR,new PdfNumber(this.duration)); duration = 0; } if (pageAA != null) { page.Put(PdfName.AA, writer.AddToBody(pageAA).IndirectReference); pageAA = null; } // [U4] we add the thumbs if (thumb != null) { page.Put(PdfName.THUMB, thumb); thumb = null; } // [U8] we check if the userunit is defined if (writer.Userunit > 0f) { page.Put(PdfName.USERUNIT, new PdfNumber(writer.Userunit)); } // [C5] and [C8] we add the annotations if (annotationsImp.HasUnusedAnnotations()) { PdfArray array = annotationsImp.RotateAnnotations(writer, pageSize); if (array.Size != 0) page.Put(PdfName.ANNOTS, array); } // [F12] we add tag info if (writer.IsTagged()) page.Put(PdfName.STRUCTPARENTS, new PdfNumber(writer.CurrentPageNumber - 1)); if (text.Size > textEmptySize) text.EndText(); else text = null; writer.Add(page, new PdfContents(writer.DirectContentUnder, graphics, text, writer.DirectContent, pageSize)); // we initialize the new page InitPage(); return true; }