本文整理匯總了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);