示例#1
0
 /**
  * Sets the transition for the page
  * @param transition   the transition object. A <code>null</code> removes the transition
  * @param page the page where the transition will be applied. The first page is 1
  */
 public void SetTransition(PdfTransition transition, int page)
 {
     stamper.SetTransition(transition, page);
 }
示例#2
0
 /**
 * Sets the transition for the page
 * @param transition   the transition object. A <code>null</code> removes the transition
 * @param page the page where the transition will be applied. The first page is 1
 */
 public void SetTransition(PdfTransition transition, int page)
 {
     stamper.SetTransition(transition, page);
 }
示例#3
0
 /**
 * Sets the transition for the page
 * @param transition   the transition object. A <code>null</code> removes the transition
 * @param page the page where the transition will be applied. The first page is 1
 */
 internal void SetTransition(PdfTransition transition, int page)
 {
     PdfDictionary pg = reader.GetPageN(page);
     if (transition == null)
         pg.Remove(PdfName.TRANS);
     else
         pg.Put(PdfName.TRANS, transition.TransitionDictionary);
     MarkUsed(pg);
 }
示例#4
0
        /**
        * 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;
        }