/** * add a line to the current stream * * @param x1 the start x location in millipoints * @param y1 the start y location in millipoints * @param x2 the end x location in millipoints * @param y2 the end y location in millipoints * @param th the thickness in millipoints * @param r the red component * @param g the green component * @param b the blue component */ private void AddLine(int x1, int y1, int x2, int y2, int th, PdfColor stroke) { CloseText(); currentStream.Write("ET\nq\n" + stroke.getColorSpaceOut(false) + PdfNumber.doubleOut(x1 / 1000f) + " " + PdfNumber.doubleOut(y1 / 1000f) + " m " + PdfNumber.doubleOut(x2 / 1000f) + " " + PdfNumber.doubleOut(y2 / 1000f) + " l " + PdfNumber.doubleOut(th / 1000f) + " w S\n" + "Q\nBT\n"); }
/** * 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; }
/** * 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; }