本文整理匯總了C#中iTextSharp.text.pdf.PdfTemplate.AddTemplateReference方法的典型用法代碼示例。如果您正苦於以下問題:C# PdfTemplate.AddTemplateReference方法的具體用法?C# PdfTemplate.AddTemplateReference怎麽用?C# PdfTemplate.AddTemplateReference使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類iTextSharp.text.pdf.PdfTemplate
的用法示例。
在下文中一共展示了PdfTemplate.AddTemplateReference方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: GetAppearance
//.........這裏部分代碼省略.........
Image im = Image.GetInstance(signatureGraphic);
im.ScaleToFit(signatureRect.Width, signatureRect.Height);
Paragraph p = new Paragraph(signatureRect.Height);
// must calculate the point to draw from to make image appear in middle of column
float x = (signatureRect.Width - im.ScaledWidth) / 2;
float y = (signatureRect.Height - im.ScaledHeight) / 2;
p.Add(new Chunk(im, x, y, false));
ct2.AddElement(p);
ct2.Go();
}
if (renderingMode != RenderingMode.GRAPHIC) {
if (size <= 0) {
Rectangle sr = new Rectangle(dataRect.Width, dataRect.Height);
size = ColumnText.FitText(font, text, sr, 12, runDirection);
}
ColumnText ct = new ColumnText(t);
ct.RunDirection = runDirection;
ct.SetSimpleColumn(new Phrase(text, font), dataRect.Left, dataRect.Bottom, dataRect.Right, dataRect.Top, size, Element.ALIGN_LEFT);
ct.Go();
}
}
if (app[3] == null && !acro6Layers) {
PdfTemplate t = app[3] = new PdfTemplate(writer);
t.BoundingBox = new Rectangle(100, 100);
writer.AddDirectTemplateSimple(t, new PdfName("n3"));
t.SetLiteral("% DSBlank\n");
}
if (app[4] == null && !acro6Layers) {
PdfTemplate t = app[4] = new PdfTemplate(writer);
t.BoundingBox = new Rectangle(0, rect.Height * (1 - TOP_SECTION), rect.Right, rect.Top);
writer.AddDirectTemplateSimple(t, new PdfName("n4"));
Font font;
if (layer2Font == null)
font = new Font();
else
font = new Font(layer2Font);
float size = font.Size;
String text = "Signature Not Verified";
if (layer4Text != null)
text = layer4Text;
Rectangle sr = new Rectangle(rect.Width - 2 * MARGIN, rect.Height * TOP_SECTION - 2 * MARGIN);
size = ColumnText.FitText(font, text, sr, 15, runDirection);
ColumnText ct = new ColumnText(t);
ct.RunDirection = runDirection;
ct.SetSimpleColumn(new Phrase(text, font), MARGIN, 0, rect.Width - MARGIN, rect.Height - MARGIN, size, Element.ALIGN_LEFT);
ct.Go();
}
int rotation = writer.reader.GetPageRotation(page);
Rectangle rotated = new Rectangle(rect);
int n = rotation;
while (n > 0) {
rotated = rotated.Rotate();
n -= 90;
}
if (frm == null) {
frm = new PdfTemplate(writer);
frm.BoundingBox = rotated;
writer.AddDirectTemplateSimple(frm, new PdfName("FRM"));
float scale = Math.Min(rect.Width, rect.Height) * 0.9f;
float x = (rect.Width - scale) / 2;
float y = (rect.Height - scale) / 2;
scale /= 100;
if (rotation == 90)
frm.ConcatCTM(0, 1, -1, 0, rect.Height, 0);
else if (rotation == 180)
frm.ConcatCTM(-1, 0, 0, -1, rect.Width, rect.Height);
else if (rotation == 270)
frm.ConcatCTM(0, -1, 1, 0, 0, rect.Width);
if (reuseAppearance) {
AcroFields af = writer.GetAcroFields();
PdfIndirectReference refe = af.GetNormalAppearance(FieldName);
if (refe != null) {
frm.AddTemplateReference(refe, new PdfName("n0"), 1, 0, 0, 1, 0, 0);
}
else {
reuseAppearance = false;
if (app[0] == null) {
CreateBlankN0();
}
}
}
if (!reuseAppearance) {
frm.AddTemplate(app[0], 0, 0);
}
if (!acro6Layers)
frm.AddTemplate(app[1], scale, 0, 0, scale, x, y);
frm.AddTemplate(app[2], 0, 0);
if (!acro6Layers) {
frm.AddTemplate(app[3], scale, 0, 0, scale, x, y);
frm.AddTemplate(app[4], 0, 0);
}
}
PdfTemplate napp = new PdfTemplate(writer);
napp.BoundingBox = rotated;
writer.AddDirectTemplateSimple(napp, null);
napp.AddTemplate(frm, 0, 0);
return napp;
}