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


C# PdfTemplate.AddImage方法代碼示例

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


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

示例1: GetAppearance


//.........這裏部分代碼省略.........
                     nlayout = LAYOUT_ICON_ONLY;
                     continue;
                 }
                 nw = box.Width * 0.35f - offX;
                 if (nw > 0)
                     fsize = CalculateFontSize(wt, nw);
                 else
                     fsize = 4;
                 if (ufont.GetWidthPoint(text, fsize) >= wt) {
                     nlayout = LAYOUT_LABEL_ONLY;
                     fsize = fontSize;
                     continue;
                 }
                 textX = box.Width - ufont.GetWidthPoint(text, fsize) - offX - 1;
                 textY = (box.Height - ufont.GetFontDescriptor(BaseFont.ASCENT, fsize)) / 2;
                 iconBox = new Rectangle(box.Left + adj, box.Bottom + adj, textX - 1, box.Top - adj);
                 break;
         }
         break;
     }
     if (textY < box.Bottom + offX)
         textY = box.Bottom + offX;
     if (iconBox != null && (iconBox.Width <= 0 || iconBox.Height <= 0))
         iconBox = null;
     bool haveIcon = false;
     float boundingBoxWidth = 0;
     float boundingBoxHeight = 0;
     PdfArray matrix = null;
     if (iconBox != null) {
         if (image != null) {
             tp = new PdfTemplate(writer);
             tp.BoundingBox = new Rectangle(image);
             writer.AddDirectTemplateSimple(tp, PdfName.FRM);
             tp.AddImage(image, image.Width, 0, 0, image.Height, 0, 0);
             haveIcon = true;
             boundingBoxWidth = tp.BoundingBox.Width;
             boundingBoxHeight = tp.BoundingBox.Height;
         }
         else if (template != null) {
             tp = new PdfTemplate(writer);
             tp.BoundingBox = new Rectangle(template.Width, template.Height);
             writer.AddDirectTemplateSimple(tp, PdfName.FRM);
             tp.AddTemplate(template, template.BoundingBox.Left, template.BoundingBox.Bottom);
             haveIcon = true;
             boundingBoxWidth = tp.BoundingBox.Width;
             boundingBoxHeight = tp.BoundingBox.Height;
         }
         else if (iconReference != null) {
             PdfDictionary dic = (PdfDictionary)PdfReader.GetPdfObject(iconReference);
             if (dic != null) {
                 Rectangle r2 = PdfReader.GetNormalizedRectangle(dic.GetAsArray(PdfName.BBOX));
                 matrix = dic.GetAsArray(PdfName.MATRIX);
                 haveIcon = true;
                 boundingBoxWidth = r2.Width;
                 boundingBoxHeight = r2.Height;
             }
         }
     }
     if (haveIcon) {
         float icx = iconBox.Width / boundingBoxWidth;
         float icy = iconBox.Height / boundingBoxHeight;
         if (proportionalIcon) {
             switch (scaleIcon) {
                 case SCALE_ICON_IS_TOO_BIG:
                     icx = Math.Min(icx, icy);
                     icx = Math.Min(icx, 1);
開發者ID:Gianluigi,項目名稱:dssnet,代碼行數:67,代碼來源:PushbuttonField.cs


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