當前位置: 首頁>>代碼示例>>C#>>正文


C# PdfContentByte.AddImage方法代碼示例

本文整理匯總了C#中iTextSharp.text.pdf.PdfContentByte.AddImage方法的典型用法代碼示例。如果您正苦於以下問題:C# PdfContentByte.AddImage方法的具體用法?C# PdfContentByte.AddImage怎麽用?C# PdfContentByte.AddImage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在iTextSharp.text.pdf.PdfContentByte的用法示例。


在下文中一共展示了PdfContentByte.AddImage方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Render

        protected internal override void Render(PdfContentByte cb, Vector2D offset)
        {
            if (image == null)
                image = Image.GetInstance(filepath);

            image.ScaleAbsolute((float)Size.X.Value(UnitsOfMeasure.Points), (float)Size.Y.Value(UnitsOfMeasure.Points));
            image.SetAbsolutePosition((float)offset.X.Value(UnitsOfMeasure.Points), (float)offset.Y.Value(UnitsOfMeasure.Points));

            cb.AddImage(image);
        }
開發者ID:deaddog,項目名稱:DeadDog.PDF,代碼行數:10,代碼來源:ImageObject.cs

示例2: Render_FrontBase

        private static void Render_FrontBase(PdfContentByte under, DateTime expiration)
        {
            float BORDER_WIDTH = 1.5f;

            // Draw background stripes and bars
            under.SaveState();
            under.SetRGBColorFill(0xff, 0x45, 0x00);
            under.Rectangle(0, CARD_HEIGHT - (UPPER_BAR_HEIGHT + PHOTO_BAR_HEIGHT + LOWER_BAR_HEIGHT), CARD_WIDTH, (UPPER_BAR_HEIGHT + PHOTO_BAR_HEIGHT + LOWER_BAR_HEIGHT));
            under.Fill();
            under.SetRGBColorFill(0x0, 0x0, 0x0);
            under.Rectangle(0, CARD_HEIGHT - (UPPER_BAR_HEIGHT + PHOTO_BAR_HEIGHT) - BORDER_WIDTH, CARD_WIDTH, PHOTO_BAR_HEIGHT + 2 * BORDER_WIDTH);
            under.Fill();
            under.SetRGBColorFill(0xff, 0xff, 0xff);
            under.Rectangle(0, CARD_HEIGHT - (UPPER_BAR_HEIGHT + PHOTO_BAR_HEIGHT), CARD_WIDTH, PHOTO_BAR_HEIGHT);
            under.Fill();
            under.RestoreState();

            var img = Image.GetInstance(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Content", "images", "sheriff.png"));
            img.ScaleToFit(CARD_WIDTH - PHOTO_WIDTH - 8, PHOTO_BAR_HEIGHT);
            img.SetAbsolutePosition(
                ((CARD_WIDTH - PHOTO_WIDTH) - img.ScaledWidth) / 2,
                CARD_HEIGHT - (UPPER_BAR_HEIGHT + img.ScaledHeight) - 4);

            under.AddImage(img);

            Font f = new Font(baseFont, 8) { Color = BaseColor.WHITE };

            Phrase p = new Phrase("Expiration:", f);
            ColumnText.ShowTextAligned(under, Element.ALIGN_LEFT, p, 4, CARD_HEIGHT - 10, 0);
            p = new Phrase(expiration.ToString("MM/dd/yyyy"), f);
            ColumnText.ShowTextAligned(under, Element.ALIGN_RIGHT, p, CARD_WIDTH - 4, CARD_HEIGHT - 10, 0);

            f = new Font(baseFont, 11) { Color = BaseColor.WHITE };
            p = new Phrase("King County", f);
            ColumnText.ShowTextAligned(under, Element.ALIGN_CENTER, p, CARD_WIDTH / 2, CARD_HEIGHT - 34, 0);

            f = new Font(baseFont, 14, Font.BOLD) { Color = BaseColor.WHITE };

            p = new Phrase("Search & Rescue", f);
            ColumnText.ShowTextAligned(under, Element.ALIGN_CENTER, p, CARD_WIDTH / 2, CARD_HEIGHT - 49, 0);
        }
開發者ID:mattkur,項目名稱:KCSARA-Database,代碼行數:41,代碼來源:BadgeService.cs

示例3: addCards

 private void addCards(PdfContentByte cb, int page, bool awers = true)
 {
     int start = page * perPage;
     for (int i = start; i < start + Math.Min(perPage, cardsLeft); i++)
     {
         var image = loadImage(projekt.getFullName(awers ? projekt.Karty[i].Awers : projekt.Karty[i].Rewers));
         image.SetAbsolutePosition(calculateXPosition(i % perPage, awers), calculateYPosition(i % perPage));
         image.ScaleAbsolute(imgW, imgH);
         cb.AddImage(image);
     }
     pdf.NewPage();
 }
開發者ID:TheKrystek,項目名稱:CardPrinter,代碼行數:12,代碼來源:PDFCreator.cs

示例4: WriteLineToContent


//.........這裏部分代碼省略.........
                            text.AddAnnotation(annot, true);
                        }
                        float[] paramsx = (float[])chunk.GetAttribute(Chunk.SKEW);
                        object hs = chunk.GetAttribute(Chunk.HSCALE);
                        if (paramsx != null || hs != null) {
                            float b = 0, c = 0;
                            if (paramsx != null) {
                                b = paramsx[0];
                                c = paramsx[1];
                            }
                            if (hs != null)
                                hScale = (float)hs;
                            text.SetTextMatrix(hScale, b, c, 1, xMarker, yMarker);
                        }
                        if (!isJustified)
                        {
                            if (chunk.IsAttribute(Chunk.WORD_SPACING))
                            {
                                float ws = (float)chunk.GetAttribute(Chunk.WORD_SPACING);
                                text.SetWordSpacing(ws);
                            }
                        }

                        if (chunk.IsAttribute(Chunk.CHAR_SPACING)) {
                    	    float cs = (float) chunk.GetAttribute(Chunk.CHAR_SPACING);
						    text.SetCharacterSpacing(cs);
					    }
                        if (chunk.IsImage()) {
                            Image image = chunk.Image;
                            width = chunk.ImageWidth;
                            float[] matrix = image.GetMatrix(chunk.ImageScalePercentage);
                            matrix[Image.CX] = xMarker + chunk.ImageOffsetX - matrix[Image.CX];
                            matrix[Image.CY] = yMarker + chunk.ImageOffsetY - matrix[Image.CY];
                            graphics.AddImage(image, matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
                            text.MoveText(xMarker + lastBaseFactor + chunk.ImageWidth - text.XTLM, 0);
                        }
                    }

                    xMarker += width;
                    ++chunkStrokeIdx;
                }

                if (!chunk.IsImage() && chunk.Font.CompareTo(currentFont) != 0) {
                    currentFont = chunk.Font;
                    text.SetFontAndSize(currentFont.Font, currentFont.Size);
                }
                float rise = 0;
                Object[] textRender = (Object[])chunk.GetAttribute(Chunk.TEXTRENDERMODE);
                int tr = 0;
                float strokeWidth = 1;
                BaseColor strokeColor = null;
                object fr = chunk.GetAttribute(Chunk.SUBSUPSCRIPT);
                if (textRender != null) {
                    tr = (int)textRender[0] & 3;
                    if (tr != PdfContentByte.TEXT_RENDER_MODE_FILL)
                        text.SetTextRenderingMode(tr);
                    if (tr == PdfContentByte.TEXT_RENDER_MODE_STROKE || tr == PdfContentByte.TEXT_RENDER_MODE_FILL_STROKE) {
                        strokeWidth = (float)textRender[1];
                        if (strokeWidth != 1)
                            text.SetLineWidth(strokeWidth);
                        strokeColor = (BaseColor)textRender[2];
                        if (strokeColor == null)
                            strokeColor = color;
                        if (strokeColor != null)
                            text.SetColorStroke(strokeColor);
                    }
開發者ID:NelsonSantos,項目名稱:fyiReporting-Android,代碼行數:67,代碼來源:PdfDocument.cs

示例5: Render_FrontContent

        private static void Render_FrontContent(PdfContentByte canvas, Member member)
        {
            Font f = new Font(baseFont, 12, Font.BOLD) { Color = BaseColor.WHITE };
            int bottom = CARD_HEIGHT - (UPPER_BAR_HEIGHT + PHOTO_BAR_HEIGHT) - 12 - 2;
            Phrase p = new Phrase(member.FullName, f);
            ColumnText.ShowTextAligned(canvas, Element.ALIGN_CENTER, p, CARD_WIDTH / 2, bottom, 0);

            bottom -= 14;
            f = new Font(baseFont, 12) { Color = BaseColor.WHITE };
            p = new Phrase(member.WacLevel.ToString(), f);
            ColumnText.ShowTextAligned(canvas, Element.ALIGN_CENTER, p, CARD_WIDTH / 2, bottom, 0);

            bottom -= 12;
            f = new Font(baseFont, 10, Font.BOLD) { Color = BaseColor.WHITE };
            p = new Phrase("KCSO DEM# " + member.DEM, f);
            ColumnText.ShowTextAligned(canvas, Element.ALIGN_CENTER, p, CARD_WIDTH / 2, bottom, 0);

            BarcodePDF417 barcode = new BarcodePDF417();
            barcode.SetText(string.Format("Unknown Text. To be added. King County Search and Rescue{0}{1}{2}", member.LastName, member.FirstName, member.DEM));
            barcode.CodeRows = 20;
            barcode.CodeColumns = 7;
            barcode.Options = BarcodePDF417.PDF417_FIXED_RECTANGLE;
            var img = barcode.GetImage();
            img.ScaleAbsolute(CARD_WIDTH - 30, 28);
            img.SetAbsolutePosition((CARD_WIDTH - img.ScaledWidth) / 2, CARD_HEIGHT - UPPER_BAR_HEIGHT - PHOTO_BAR_HEIGHT - LOWER_BAR_HEIGHT - img.ScaledHeight - 8);
            canvas.AddImage(img);

            if (!string.IsNullOrWhiteSpace(member.PhotoFile))
            {
                var file = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Content", "auth", "members", member.PhotoFile);
                if (File.Exists(file))
                {
                    img = Image.GetInstance(file);
                    img.ScaleToFit(PHOTO_WIDTH, PHOTO_BAR_HEIGHT);
                    img.SetAbsolutePosition(CARD_WIDTH - img.ScaledWidth, CARD_HEIGHT - (UPPER_BAR_HEIGHT + img.ScaledHeight));
                    canvas.AddImage(img);
                }
            }
        }
開發者ID:mattkur,項目名稱:KCSARA-Database,代碼行數:39,代碼來源:BadgeService.cs

示例6: Render_BackContent

        private static void Render_BackContent(PdfContentByte canvas, Member member, bool passport)
        {
            Font f = new Font(baseFont, 12, Font.BOLD);
            int bottom = CARD_HEIGHT - 32;
            Phrase p = new Phrase(member.FullName, f);
            ColumnText.ShowTextAligned(canvas, Element.ALIGN_CENTER, p, CARD_WIDTH / 2, bottom, 0);

            if (passport)
            {
                bottom = CARD_HEIGHT - 170;
                f = new Font(baseFont, 16f, Font.BOLD);
                p = new Phrase("PASSPORT", f);
                ColumnText.ShowTextAligned(canvas, Element.ALIGN_CENTER, p, CARD_WIDTH / 2, bottom, 0);
            }
            else
            {
                bottom = CARD_HEIGHT - 159;
                f = new Font(baseFont, 11f);
                p = new Phrase(member.WacLevel.ToString(), f);
                ColumnText.ShowTextAligned(canvas, Element.ALIGN_CENTER, p, CARD_WIDTH / 2, bottom, 0);

                bottom -= 12;
                p = new Phrase("KCSO DEM# " + member.DEM, f);
                ColumnText.ShowTextAligned(canvas, Element.ALIGN_CENTER, p, CARD_WIDTH / 2, bottom, 0);
            }

            BarcodePDF417 barcode = new BarcodePDF417();
            barcode.SetText(string.Format("Unknown Text. To be added. KCSAR{0}{1}{2}", member.LastName, member.FirstName, member.DEM));
            barcode.CodeRows = 9;
            barcode.CodeColumns = 7;
            barcode.Options = BarcodePDF417.PDF417_FIXED_RECTANGLE;
            var img = barcode.GetImage();
            img.ScaleAbsolute(CARD_WIDTH - 30, 14);
            img.SetAbsolutePosition((CARD_WIDTH - img.ScaledWidth) / 2, 50);
            canvas.AddImage(img);
        }
開發者ID:mattkur,項目名稱:KCSARA-Database,代碼行數:36,代碼來源:BadgeService.cs

示例7: RenderLogo

 private void RenderLogo()
 {
     cb = writer.DirectContent;
     iTextSharp.text.Image Logo = iTextSharp.text.Image.GetInstance(HttpContext.Current.Server.MapPath(this.LogoImagePath));
     //Logo.ScaleToFit(200, 43);
     Logo.SetAbsolutePosition(35, 720);
     cb.AddImage(Logo);
 }
開發者ID:paulallies,項目名稱:tsdt,代碼行數:8,代碼來源:Report.cs

示例8: WriteLineToContent


//.........這裏部分代碼省略.........
                            if (pev != null)
                                pev.OnGenericTag(writer, this, rect, (String)chunk.GetAttribute(Chunk.GENERICTAG));
                        }
                        if (chunk.IsAttribute(Chunk.PDFANNOTATION)) {
                            float subtract = lastBaseFactor;
                            if (nextChunk != null && nextChunk.IsAttribute(Chunk.PDFANNOTATION))
                                subtract = 0;
                            if (nextChunk == null)
                                subtract += hangingCorrection;
                            float fontSize = chunk.Font.Size;
                            float ascender = chunk.Font.Font.GetFontDescriptor(BaseFont.ASCENT, fontSize);
                            float descender = chunk.Font.Font.GetFontDescriptor(BaseFont.DESCENT, fontSize);
                            PdfAnnotation annot = PdfFormField.ShallowDuplicate((PdfAnnotation)chunk.GetAttribute(Chunk.PDFANNOTATION));
                            annot.Put(PdfName.RECT, new PdfRectangle(xMarker, yMarker + descender, xMarker + width - subtract, yMarker + ascender));
                            text.AddAnnotation(annot);
                        }
                        float[] paramsx = (float[])chunk.GetAttribute(Chunk.SKEW);
                        object hs = chunk.GetAttribute(Chunk.HSCALE);
                        if (paramsx != null || hs != null) {
                            float b = 0, c = 0;
                            if (paramsx != null) {
                                b = paramsx[0];
                                c = paramsx[1];
                            }
                            if (hs != null)
                                hScale = (float)hs;
                            text.SetTextMatrix(hScale, b, c, 1, xMarker, yMarker);
                        }
                        if (chunk.IsImage()) {
                            Image image = chunk.Image;
                            float[] matrix = image.Matrix;
                            matrix[Image.CX] = xMarker + chunk.ImageOffsetX - matrix[Image.CX];
                            matrix[Image.CY] = yMarker + chunk.ImageOffsetY - matrix[Image.CY];
                            graphics.AddImage(image, matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
                            text.MoveText(xMarker + lastBaseFactor + image.ScaledWidth - text.XTLM, 0);
                        }
                    }
                    xMarker += width;
                    ++chunkStrokeIdx;
                }

                if (chunk.Font.CompareTo(currentFont) != 0) {
                    currentFont = chunk.Font;
                    text.SetFontAndSize(currentFont.Font, currentFont.Size);
                }
                float rise = 0;
                Object[] textRender = (Object[])chunk.GetAttribute(Chunk.TEXTRENDERMODE);
                int tr = 0;
                float strokeWidth = 1;
                Color strokeColor = null;
                object fr = chunk.GetAttribute(Chunk.SUBSUPSCRIPT);
                if (textRender != null) {
                    tr = (int)textRender[0] & 3;
                    if (tr != PdfContentByte.TEXT_RENDER_MODE_FILL)
                        text.SetTextRenderingMode(tr);
                    if (tr == PdfContentByte.TEXT_RENDER_MODE_STROKE || tr == PdfContentByte.TEXT_RENDER_MODE_FILL_STROKE) {
                        strokeWidth = (float)textRender[1];
                        if (strokeWidth != 1)
                            text.SetLineWidth(strokeWidth);
                        strokeColor = (Color)textRender[2];
                        if (strokeColor == null)
                            strokeColor = color;
                        if (strokeColor != null)
                            text.SetColorStroke(strokeColor);
                    }
                }
開發者ID:hjgode,項目名稱:iTextSharpCF,代碼行數:67,代碼來源:PdfDocument.cs

示例9: Layout


//.........這裏部分代碼省略.........
            {
                float? translationX = null;
                if (left != null)
                    translationX = left;
                else if (right != null)
                    translationX = -right;
                else
                    translationX = 0f;

                float? translationY = null;
                if (top != null)
                    translationY = -top;
                else if (bottom != null)
                    translationY = bottom;
                else
                    translationY = 0f;
                canvas.SaveState();
                canvas.Transform(new AffineTransform(1f, 0, 0, 1f, translationX.Value, translationY.Value));
            }

            if (!simulate)
            {
                if ((backgroundColor != null || backgroundImage != null) && getActualWidth() > 0 && getActualHeight() > 0)
                {
                    float backgroundWidth = getActualWidth();
                    float backgroundHeight = getActualHeight();
                    if (width != null)
                        backgroundWidth = width > 0 ? (float) width : 0;
                    if (height != null)
                        backgroundHeight = height > 0 ? (float) height : 0;
                    if (backgroundWidth > 0 && backgroundHeight > 0)
                    {
                        Rectangle background = new Rectangle(leftX, maxY - backgroundHeight, leftX + backgroundWidth, maxY);
                        if (backgroundColor != null) {
                            background.BackgroundColor = backgroundColor;
                            PdfArtifact artifact = new PdfArtifact();
                            canvas.OpenMCBlock(artifact);
                            canvas.Rectangle(background);
                            canvas.CloseMCBlock(artifact);
                        }
                        if (backgroundImage != null) {
                            if (backgroundImageWidth == null) {
                                backgroundImage.ScaleToFit(background);
                            }
                            else {
                                backgroundImage.ScaleAbsolute((float)backgroundImageWidth, backgroundImageHeight);
                            }
                            backgroundImage.SetAbsolutePosition(background.Left, background.Bottom);
                            canvas.OpenMCBlock(backgroundImage);
                            canvas.AddImage(backgroundImage);
                            canvas.CloseMCBlock(backgroundImage);
                        }
                    }
                }
            }

            if (percentageWidth == null)
                contentWidth = 0;
            if (percentageHeight == null)
                contentHeight = 0;

            minY += paddingBottom;
            leftX += paddingLeft;
            rightX -= paddingRight;

            yLine -= paddingTop;

            int status = ColumnText.NO_MORE_TEXT;

            if (content.Count > 0) {
                if (floatLayout == null) {
                    List<IElement> floatingElements = new List<IElement>(content);
                    floatLayout = new FloatLayout(floatingElements, useAscender);
                    floatLayout.RunDirection = runDirection;
                }

                floatLayout.SetSimpleColumn(leftX, minY, rightX, yLine);
                if (borderTopStyle != BorderTopStyle.NONE)
                    floatLayout.compositeColumn.IgnoreSpacingBefore = false;
                status = floatLayout.Layout(canvas, simulate);
                yLine = floatLayout.YLine;

                if (percentageWidth == null && contentWidth < floatLayout.FilledWidth) {
                    contentWidth = floatLayout.FilledWidth;
                }
            }


            if (!simulate && position == PdfDiv.PositionType.RELATIVE)
                canvas.RestoreState();

            yLine -= paddingBottom;
            if (percentageHeight == null)
                contentHeight = maxY - yLine;

            if (percentageWidth == null)
                contentWidth += paddingLeft + paddingRight;

            return contentCutByFixedHeight ? ColumnText.NO_MORE_TEXT : status;
        }
開發者ID:joshaxey,項目名稱:Simple-PDFMerge,代碼行數:101,代碼來源:PdfDiv.cs

示例10: RenderPurchaseOrder

        public void RenderPurchaseOrder(Stream stream, int PoNumber, IEnumerable<PoItemModel> PoItems, int RequestNumber, string VendorName, string VendorCode, string VendorAddress, DateTime DateCreated, DateTime DeliveryDate, UserModel RequestUser, UserModel CurrentUser)
        {
            Document document = new Document(PageSize.LETTER);

            try {
                PdfWriter writer = PdfWriter.GetInstance(document, stream);
                document.Open();

                // Create a page in the document and add it to the bottom layer
                document.NewPage();
                //Pass Document to this
                CurrentDoc = document;

                string logoLocation = sonicLogo;
                float logoPosition = 50;

                string CurrentCompany = RequestUser.CompanyName;
                //Image
                if (RequestUser.CompanyId == (int)CompanyIds.SonicSteel) {
                    logoLocation = sonicLogo;
                    logoPosition = 70;
                }
                else if (RequestUser.CompanyId == (int)CompanyIds.SteelTech) {
                    logoLocation = steeltechLogo;
                }
                else if (RequestUser.CompanyId == (int)CompanyIds.Somico) {
                    logoLocation = somicoLogo;
                }
                Image logo = Image.GetInstance(Directory.GetCurrentDirectory() + logoLocation);
                logo.SetAbsolutePosition(20, (int)CurrentDoc.GetTop(logoPosition));

                // START HERE ----------------------------
                Paragraph Grid = new Paragraph("\n\n\n\n\n\n\n\n\n");
                Grid.Alignment = 1;
                Grid.SpacingAfter = 35f;
                document.Add(Grid);

                Paragraph Grid2 = new Paragraph();
                Grid2.Alignment = 1;
                Grid2.SpacingBefore = 35f;
                //Start Table -----------------------------------
                PdfPTable rightTable = new PdfPTable(7);
                int[] widths = { 1, 1, 1, 7, 2, 2, 2 };
                rightTable.SetWidths(widths);
                rightTable.TotalWidth = 570f;
                rightTable.LockedWidth = true;
                Font tableFont = new Font(Font.FontFamily.HELVETICA, 8);

                rightTable.HorizontalAlignment = Element.ALIGN_CENTER;

                rightTable.AddCell(new Phrase("Item No.", tableFont));
                rightTable.AddCell(new Phrase("Quantity", tableFont));
                rightTable.AddCell(new Phrase("UOM", tableFont));
                rightTable.AddCell(new Phrase("Item Description", tableFont));
                rightTable.AddCell(new Phrase("Unit Price", tableFont));
                rightTable.AddCell(new Phrase("Discount", tableFont));
                rightTable.AddCell(new Phrase("Total Amount", tableFont));

                rightTable.HorizontalAlignment = Element.ALIGN_LEFT;

                int itemCount = 1;
                foreach (var poItem in PoItems) {
                    rightTable.AddCell(new Phrase(itemCount.ToString(), tableFont)); rightTable.AddCell(new Phrase(poItem.Quantity.ToString(), tableFont)); rightTable.AddCell(new Phrase(poItem.UOM, tableFont)); rightTable.AddCell(new Phrase(poItem.Description, tableFont)); rightTable.AddCell(new Phrase(poItem.Price.ToString(), tableFont)); rightTable.AddCell(new Phrase(poItem.Discount.ToString(), tableFont)); rightTable.AddCell(new Phrase(poItem.TotalPrice.ToString(), tableFont));
                    itemCount++;
                }
                //Nothing Follows
                rightTable.AddCell(new Phrase("", tableFont)); rightTable.AddCell(new Phrase("", tableFont)); rightTable.AddCell(new Phrase("")); rightTable.AddCell(new Phrase("******** NOTHING FOLLOWS ********", tableFont)); rightTable.AddCell(new Phrase("")); rightTable.AddCell(new Phrase("")); rightTable.AddCell(new Phrase(""));

                //Grand Total
                rightTable.AddCell(new Phrase("", tableFont)); rightTable.AddCell(new Phrase("", tableFont)); rightTable.AddCell(new Phrase("")); rightTable.AddCell(new Phrase("", tableFont)); rightTable.AddCell(new Phrase("")); rightTable.AddCell(new Phrase("Grand Total:", new Font(Font.FontFamily.HELVETICA, 12))); rightTable.AddCell(new Phrase(PoItems.Sum(x => x.TotalPrice).ToString(), new Font(Font.FontFamily.HELVETICA, 12)));

                Grid2.Add(rightTable);
                document.Add(Grid2);
                // End of table -----------------------------------
                page = writer.DirectContentUnder;

                page.AddImage(logo);
                page.Stroke();

                // For "Purchase Order" Text
                PrintRectangle(20, 120, 570, 50);
                //For two tables
                PrintRectangle(20, 230, 350, 100);
                PrintRectangle(370, 230, 220, 100);
                //For Footer
                PrintRectangleBottom(20, 20, 570, 50);

                page.BeginText();

                SetFontSizeTo(24);

                PrintText("PURCHASE ORDER", 180, 105);

                SetPOCompanyHeader(RequestUser);

                SetFontSizeTo(10);
                // Header
                PrintText("To:", 25, 140); // Vendor Name

                SetFontSizeTo(8);
//.........這裏部分代碼省略.........
開發者ID:haroldocampo,項目名稱:PRSSSI,代碼行數:101,代碼來源:PdfManager.cs

示例11: RenderImageElement

 private void RenderImageElement(ImageElement el, PdfContentByte dc)
 {
     using (var stream = new MemoryStream(el.Data))
     using (var stream2 = new MemoryStream())
     {
         var img = System.Drawing.Image.FromStream(stream);
         using (Bitmap b = new Bitmap(img.Width, img.Height))
         {
             using (Graphics g = Graphics.FromImage(b))
             {
                 g.Clear(Color.White);
                 g.DrawImageUnscaledAndClipped(img, new System.Drawing.Rectangle(0, 0, img.Width, img.Height));
             }
             b.Save(stream2, ImageFormat.Png);
             stream2.Position = 0;
         }
         var image = iTextSharp.text.Image.GetInstance(stream2);
         float w, h;
         w = el.Width;
         h = img.Height * el.Width / img.Width;
         image.ScaleAbsolute(w, h);
         image.SetAbsolutePosition(TranslateLeft(el), doc.PageSize.Height - marginTop - h);
         dc.AddImage(image);
     }
 }
開發者ID:koraytaylan,項目名稱:ReportSharp,代碼行數:25,代碼來源:PdfRenderer.cs

示例12: DrawImageAndText

 // ---------------------------------------------------------------------------
 /**
  * Draws the image of the month to the calendar.
  * @param canvas the direct content layer
  * @param dt the DateTime (to know which picture to use)
  */
 public void DrawImageAndText(PdfContentByte canvas, DateTime dt)
 {
     string MM = dt.ToString("MM");
     // get the image
     Image img = Image.GetInstance(Path.Combine(
       RESOURCE, MM + ".jpg"
     ));
     img.ScaleToFit(PageSize.A4.Height, PageSize.A4.Width);
     img.SetAbsolutePosition(
       (PageSize.A4.Height - img.ScaledWidth) / 2,
       (PageSize.A4.Width - img.ScaledHeight) / 2
     );
     canvas.AddImage(img);
     // add metadata
     canvas.SaveState();
     canvas.SetCMYKColorFill(0x00, 0x00, 0x00, 0x80);
     Phrase p = new Phrase(string.Format(
         "{0} - \u00a9 Katharine Osborne",
         content[string.Format("{0}.jpg", dt.ToString("MM"))]
       ),
       small
     );
     ColumnText.ShowTextAligned(canvas, Element.ALIGN_LEFT, p, 5, 5, 0);
     p = new Phrase(
       "Calendar generated using iText - example for the book iText in Action 2nd Edition",
       small
     );
     ColumnText.ShowTextAligned(canvas, Element.ALIGN_RIGHT, p, 839, 5, 0);
     canvas.RestoreState();
 }
開發者ID:kuujinbo,項目名稱:iTextInAction2Ed,代碼行數:36,代碼來源:PdfCalendar.cs

示例13: CreatePdfOverviewMap

  private void CreatePdfOverviewMap(PdfContentByte content, Configuration.PrintTemplateContentRow row)
  {
    AppState appState = new AppState();
    appState.Application = _appState.Application;
    Configuration.ApplicationRow application = AppContext.GetConfiguration().Application.First(o => o.ApplicationID == appState.Application);

    appState.MapTab = application.OverviewMapID;
    appState.Extent = application.GetFullExtentEnvelope();

    int pixelWidth = Convert.ToInt32(row.Width * PixelsPerInch);
    int pixelHeight = Convert.ToInt32(row.Height * PixelsPerInch);

    MapMaker mapMaker = new MapMaker(appState, pixelWidth, pixelHeight, 2);
    MapImageData mapImageData = mapMaker.GetImage();

    System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(new MemoryStream(mapImageData.Image));
    Transformation trans = new AffineTransformation(pixelWidth * 2, pixelHeight * 2, appState.Extent);
    MapGraphics mapGraphics = MapGraphics.FromImage(bitmap, trans);

    double minSize = (trans.Transform(new Coordinate(1, 0)).X - trans.Transform(new Coordinate(0, 0)).X) * 12;
    Envelope extent = new Envelope(new Coordinate(_appState.Extent.MinX, _appState.Extent.MinY), new Coordinate(_appState.Extent.MaxX, _appState.Extent.MaxY));

    if (extent.Width < minSize)
    {
      extent = new Envelope(new Coordinate(extent.Centre.X - minSize * 0.5, extent.MinY), new Coordinate(extent.Centre.X + minSize * 0.5, extent.MaxY));
    }

    if (extent.Height < minSize)
    {
      extent = new Envelope(new Coordinate(extent.MinX, extent.Centre.Y - minSize * 0.5), new Coordinate(extent.MaxX, extent.Centre.Y + minSize * 0.5));
    }

    System.Drawing.Brush brush = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(64, System.Drawing.Color.Red));
    System.Drawing.Pen pen = new System.Drawing.Pen(System.Drawing.Color.Red, 4);

    mapGraphics.FillEnvelope(brush, extent);
    mapGraphics.DrawEnvelope(pen, extent);

    MemoryStream stream = new MemoryStream();
    bitmap.Save(stream, mapImageData.Type == CommonImageType.Png ? System.Drawing.Imaging.ImageFormat.Png : System.Drawing.Imaging.ImageFormat.Jpeg);
    byte[] mapImage = stream.ToArray();

    float originX = Convert.ToSingle(row.OriginX) * PointsPerInch;
    float originY = Convert.ToSingle(row.OriginY) * PointsPerInch;
    float width = Convert.ToSingle(row.Width) * PointsPerInch;
    float height = Convert.ToSingle(row.Height) * PointsPerInch;

    iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(mapImage);
    image.SetAbsolutePosition(originX, originY);
    image.ScaleAbsolute(width, height);

    content.AddImage(image);

    CreatePdfBox(content, row, false);
  }
開發者ID:ClaireBrill,項目名稱:GPV,代碼行數:55,代碼來源:PdfMap.cs

示例14: CreatePdfMap

	private void CreatePdfMap(PdfContentByte content, Configuration.PrintTemplateContentRow row)
	{
		int pixelWidth = Convert.ToInt32(row.Width * PixelsPerInch);
		int pixelHeight = Convert.ToInt32(row.Height * PixelsPerInch);

		MapMaker mapMaker = new MapMaker(_appState, pixelWidth, pixelHeight, 2);
		byte[] mapImage = mapMaker.GetImage().Image;

		float originX = Convert.ToSingle(row.OriginX) * PointsPerInch;
		float originY = Convert.ToSingle(row.OriginY) * PointsPerInch;
		float width = Convert.ToSingle(row.Width) * PointsPerInch;
		float height = Convert.ToSingle(row.Height) * PointsPerInch;

		iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(mapImage);
		image.SetAbsolutePosition(originX, originY);
		image.ScaleAbsolute(width, height);

		content.AddImage(image);

		CreatePdfBox(content, row, false);
	}
開發者ID:ClaireBrill,項目名稱:GPV,代碼行數:21,代碼來源:PdfMap.cs

示例15: CreateLayerInLegend

  private bool CreateLayerInLegend(PdfContentByte content, Configuration.MapTabRow mapTab, List<CommonLayer> layerList, LegendProperties properties, CommonLayer layer, float indent)
  {
    if (!layerList.Contains(layer))
    {
      return false;
    }

    float layerHeight = GetLayerHeightInLegend(layerList, properties, layer);

    if (properties.CurrentY < properties.Height && properties.CurrentY - layerHeight < 0)
    {
      if (properties.CurrentColumn == properties.NumColumns)
      {
        return true;
      }

      properties.CurrentX += properties.ColumnWidth + properties.ColumnSpacing;
      properties.CurrentY = properties.Height;
      properties.CurrentColumn += 1;
    }

    int numClasses = GetNumClasses(layer);

    Configuration.LayerRow configLayer = mapTab.GetMapTabLayerRows().Where(o => String.Compare(o.LayerRow.LayerName, layer.Name, true) == 0).Select(o => o.LayerRow).FirstOrDefault();
    string layerName = configLayer != null && !configLayer.IsDisplayNameNull() ? configLayer.DisplayName : layer.Name;

    // write the layer name

    if (layer.Type == CommonLayerType.Group || numClasses > 1)
    {
      properties.CurrentY -= properties.FontSize;
      string name = layerName;

      try
      {
        while (content.GetEffectiveStringWidth(name, false) > properties.ColumnWidth - indent)
        {
          name = name.Substring(0, name.Length - 1);
        }
      }
      catch { }

      content.BeginText();
      content.SetFontAndSize(properties.BaseFont, properties.FontSize);
      content.SetRGBColorFill(0, 0, 0);
      content.ShowTextAligned(PdfContentByte.ALIGN_LEFT, name, properties.OriginX + properties.CurrentX + indent, properties.OriginY + properties.CurrentY + (properties.SwatchHeight - properties.FontSize) / 2, 0);
      content.EndText();
    }

    if (layer.Type == CommonLayerType.Group)
    {
      properties.CurrentY -= properties.LayerSpacing;

      foreach (CommonLayer childLayer in layer.Children)
      {
        CreateLayerInLegend(content, mapTab, layerList, properties, childLayer, indent + 1.5f * properties.FontSize);
      }
    }
    else
    {
      properties.CurrentY -= properties.ClassSpacing;

      foreach (CommonLegendGroup legendGroup in layer.Legend.Groups)
      {
        foreach (CommonLegendClass legendClass in legendGroup.Classes)
        {
          if (!legendClass.ImageIsTransparent)
          {
            properties.CurrentY -= properties.SwatchHeight;

            MemoryStream stream = new MemoryStream(legendClass.Image);
            System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(stream);
            float w = properties.SwatchHeight * bitmap.Width / bitmap.Height;

            iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(legendClass.Image);
            image.SetAbsolutePosition(properties.OriginX + properties.CurrentX + indent, properties.OriginY + properties.CurrentY - properties.SwatchHeight * 0.1f);
            image.ScaleAbsolute(w, properties.SwatchHeight);
            content.AddImage(image);

            string label = numClasses > 1 ? legendClass.Label : layerName;

            try
            {
              while (content.GetEffectiveStringWidth(label, false) > properties.ColumnWidth - properties.SwatchWidth - properties.ClassSpacing)
              {
                label = label.Substring(0, label.Length - 1);
              }
            }
            catch { }

            content.BeginText();
            content.SetFontAndSize(properties.BaseFont, properties.FontSize);
            content.SetRGBColorFill(0, 0, 0);
            content.ShowTextAligned(PdfContentByte.ALIGN_LEFT, label, properties.OriginX + properties.CurrentX + indent + properties.SwatchWidth + properties.ClassSpacing, properties.OriginY + properties.CurrentY + (properties.SwatchHeight - properties.FontSize) / 2, 0);
            content.EndText();

            properties.CurrentY -= properties.ClassSpacing;
          }
        }
      }
//.........這裏部分代碼省略.........
開發者ID:ClaireBrill,項目名稱:GPV,代碼行數:101,代碼來源:PdfMap.cs


注:本文中的iTextSharp.text.pdf.PdfContentByte.AddImage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。