/** * Draws the point, text and borders of this cell. * */ internal virtual void Paint( Page page, float x, float y, float w, float h) { if (background != -1) { DrawBackground(page, x, y, w, h); } if (image != null) { image.SetLocation(x + left_padding, y + top_padding); image.DrawOn(page); } DrawBorders(page, x, y, w, h); if (text != null) { DrawText(page, x, y, w); } if (point != null) { if (point.align == Align.LEFT) { point.x = x + 2 * point.r; } else if (point.align == Align.RIGHT) { point.x = (x + w) - this.right_padding / 2; } point.y = y + h / 2; page.SetBrushColor(point.GetColor()); if (point.GetURIAction() != null) { page.AddAnnotation(new Annotation( point.GetURIAction(), null, point.x - point.r, page.height - (point.y - point.r), point.x + point.r, page.height - (point.y + point.r), null, null, null)); } page.DrawPoint(point); } }
public static float DrawImg(PDF pdf, Page page, string imgfile, float offsetY) { System.Drawing.Image image = System.Drawing.Image.FromFile(imgfile); double val = (double)pdfUtil.PDFpageeffwidth / (double)image.Width; double val2 = (double)(pdfUtil.PDFpageeffHeight - offsetY) / (double)image.Height; double factor = System.Math.Min(val, val2); PDFjet.NET.Image image2 = new PDFjet.NET.Image(pdf, new System.IO.BufferedStream(new System.IO.FileStream(imgfile, System.IO.FileMode.Open, System.IO.FileAccess.Read)), ImageType.JPG); image2.SetLocation(pdfUtil.PDFleft_margin, pdfUtil.PDFtop_margin + offsetY); image2.ScaleBy(factor); image2.DrawOn(page); return(image2.GetHeight()); }
/** * Draws the point, text and borders of this cell. */ internal void Paint( Page page, float x, float y, float w, float h) { if (background != -1) { DrawBackground(page, x, y, w, h); } if (image != null) { if (GetTextAlignment() == Align.LEFT) { image.SetLocation(x + leftPadding, y + topPadding); image.DrawOn(page); } else if (GetTextAlignment() == Align.CENTER) { image.SetLocation((x + w / 2f) - image.GetWidth() / 2f, y + topPadding); image.DrawOn(page); } else if (GetTextAlignment() == Align.RIGHT) { image.SetLocation((x + w) - (image.GetWidth() + leftPadding), y + topPadding); image.DrawOn(page); } } if (barCode != null) { try { if (GetTextAlignment() == Align.LEFT) { barCode.DrawOnPageAtLocation(page, x + leftPadding, y + topPadding); } else if (GetTextAlignment() == Align.CENTER) { float barcodeWidth = barCode.DrawOn(null)[0]; barCode.DrawOnPageAtLocation(page, (x + w / 2f) - barcodeWidth / 2f, y + topPadding); } else if (GetTextAlignment() == Align.RIGHT) { float barcodeWidth = barCode.DrawOn(null)[0]; barCode.DrawOnPageAtLocation(page, (x + w) - (barcodeWidth + leftPadding), y + topPadding); } } catch (Exception e) { Console.WriteLine(e.ToString()); } } if (textBlock != null) { textBlock.SetLocation(x + leftPadding, y + topPadding); textBlock.DrawOn(page); } DrawBorders(page, x, y, w, h); if (text != null && !text.Equals("")) { DrawText(page, x, y, w, h); } if (point != null) { if (point.align == Align.LEFT) { point.x = x + 2 * point.r; } else if (point.align == Align.RIGHT) { point.x = (x + w) - this.rightPadding / 2; } point.y = y + h / 2; page.SetBrushColor(point.GetColor()); if (point.GetURIAction() != null) { page.AddAnnotation(new Annotation( point.GetURIAction(), null, point.x - point.r, point.y - point.r, point.x + point.r, point.y + point.r, null, null, null)); } page.DrawPoint(point); } if (drawable != null) { drawable.SetPosition(x + leftPadding, y + topPadding); drawable.DrawOn(page); } }
public Example_03() { FileStream fos = new FileStream("Example_03.pdf", FileMode.Create); BufferedStream bos = new BufferedStream(fos); PDF pdf = new PDF(bos); pdf.setCompressor(Compressor.ORIGINAL_ZLIB); // Before you enable this flag please read README.ZLIB.TXT // in the 'optional' directory. // Font f1 = new Font(pdf, "Helvetica"); /* Font f1 = new Font(pdf, new FileStream( "fonts/DroidFonts/DroidSans.otf", FileMode.Open), CodePage.UNICODE, Embed.YES); */ String fileName = "images/eu-map.png"; FileStream fis1 = new FileStream(fileName, FileMode.Open); Image image1 = new Image(pdf, fis1, ImageType.PNG); fileName = "images/fruit.jpg"; FileStream fis2 = new FileStream(fileName, FileMode.Open); Image image2 = new Image(pdf, fis2, ImageType.JPEG); fileName = "images/mt-map.bmp"; FileStream fis3 = new FileStream(fileName, FileMode.Open); Image image3 = new Image(pdf, fis3, ImageType.BMP); Page page = new Page(pdf, A4.PORTRAIT); /* TextLine text = new TextLine(f1, "The map below is an embedded PNG image"); text.SetPosition(90, 30); text.DrawOn(page); */ image1.SetPosition(90, 40); image1.DrawOn(page); /* text.SetText( "JPG image file embedded once and drawn 3 times"); text.SetPosition(90, 550); text.DrawOn(page); */ image2.SetPosition(90, 560); image2.ScaleBy(0.5); image2.DrawOn(page); image2.SetPosition(260, 560); image2.ScaleBy(0.5); image2.DrawOn(page); image2.SetPosition(350, 560); image2.ScaleBy(0.5); image2.DrawOn(page); /* text.SetText( "The map on the right is an embedded BMP image"); text.SetUnderline(true); text.SetStrikeLine(true); text.SetTextDirection(15); text.SetPosition(90, 800); text.DrawOn(page); */ image3.SetPosition(390, 630); image3.ScaleBy(0.5); image3.DrawOn(page); pdf.Flush(); bos.Close(); }