Ejemplo n.º 1
0
        public void StopRenderer() {
            fontSetup.AddToResources(new PdfFontCreator(pdfDoc), pdfDoc.getResources());
            pdfDoc.outputTrailer();

            pdfDoc = null;
            pdfResources = null;
            currentStream = null;
            currentAnnotList = null;
            currentPage = null;

            idReferences = null;
            currentFontName = String.Empty;
            currentFill = null;
            prevUnderlineColor = null;
            prevOverlineColor = null;
            prevLineThroughColor = null;
            fontSetup = null;
            fontInfo = null;
        }
Ejemplo n.º 2
0
        /**
        * render page into PDF
        *
        * @param page page to render
        */

        public void RenderPage(Page page) {
            BodyAreaContainer body;
            AreaContainer before, after, start, end;

            currentStream = this.pdfDoc.makeContentStream();
            body = page.getBody();
            before = page.getBefore();
            after = page.getAfter();
            start = page.getStart();
            end = page.getEnd();

            this.currentFontName = "";
            this.currentFontSize = 0;
            this.currentLetterSpacing = Single.NaN;

            currentStream.Write("BT\n");

            RenderBodyAreaContainer(body);

            if (before != null) {
                RenderAreaContainer(before);
            }

            if (after != null) {
                RenderAreaContainer(after);
            }

            if (start != null) {
                RenderAreaContainer(start);
            }

            if (end != null) {
                RenderAreaContainer(end);
            }
            CloseText();

            // Bug fix for issue 1823
            this.currentLetterSpacing = Single.NaN;

            float w = page.getWidth();
            float h = page.GetHeight();
            currentStream.Write("ET\n");

            currentPage = this.pdfDoc.makePage(
                this.pdfResources, currentStream,
                Convert.ToInt32(Math.Round(w/1000)),
                Convert.ToInt32(Math.Round(h/1000)), page);

            if (page.hasLinks() || currentAnnotList != null) {
                if (currentAnnotList == null) {
                    currentAnnotList = this.pdfDoc.makeAnnotList();
                }
                currentPage.SetAnnotList(currentAnnotList);

                ArrayList lsets = page.getLinkSets();
                foreach (LinkSet linkSet in lsets) {
                    linkSet.align();
                    String dest = linkSet.getDest();
                    int linkType = linkSet.getLinkType();
                    ArrayList rsets = linkSet.getRects();
                    foreach (LinkedRectangle lrect in rsets) {
                        currentAnnotList.Add(this.pdfDoc.makeLink(lrect.getRectangle(),
                                                                  dest, linkType).GetReference());
                    }
                }
                currentAnnotList = null;
            }
            else {
                // just to be on the safe side
                currentAnnotList = null;
            }

            // ensures that color is properly reset for blocks that carry over pages
            this.currentFill = null;
        }
Ejemplo n.º 3
0
        public PdfPage makePage(PdfResources resources, PdfContentStream contents,
                                int pagewidth, int pageheight, Page currentPage)
        {
            PdfPage page = new PdfPage(
                resources, contents,
                pagewidth, pageheight,
                doc.NextObjectId());

            if (currentPage != null)
            {
                foreach (string id in currentPage.getIDList())
                {
                    idReferences.setInternalGoToPageReference(id, page.GetReference());
                }
            }

            /* add it to the list of objects */
            this.objects.Add(page);

            page.SetParent(doc.Pages);
            doc.Pages.Kids.Add(page.GetReference());

            return page;
        }