本文整理汇总了C#中iTextSharp.text.pdf.PdfTemplate类的典型用法代码示例。如果您正苦于以下问题:C# PdfTemplate类的具体用法?C# PdfTemplate怎么用?C# PdfTemplate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PdfTemplate类属于iTextSharp.text.pdf命名空间,在下文中一共展示了PdfTemplate类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ImgTemplate
/// <summary>
/// Creats an Image from a PdfTemplate.
/// </summary>
/// <param name="template">the PdfTemplate</param>
public ImgTemplate(PdfTemplate template) : base((Uri)null) {
if (template == null)
throw new BadElementException(MessageLocalization.GetComposedMessage("the.template.can.not.be.null"));
if (template.Type == PdfTemplate.TYPE_PATTERN)
throw new BadElementException(MessageLocalization.GetComposedMessage("a.pattern.can.not.be.used.as.a.template.to.create.an.image"));
type = Element.IMGTEMPLATE;
scaledHeight = template.Height;
this.Top = scaledHeight;
scaledWidth = template.Width;
this.Right = scaledWidth;
TemplateData = template;
plainWidth = this.Width;
plainHeight = this.Height;
}
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:18,代码来源:ImgTemplate.cs
示例2: ImgTemplate
/// <summary>
/// Creats an Image from a PdfTemplate.
/// </summary>
/// <param name="template">the PdfTemplate</param>
public ImgTemplate(PdfTemplate template)
: base((Uri)null)
{
if (template == null)
throw new BadElementException("The template can not be null.");
if (template.Type == PdfTemplate.TYPE_PATTERN)
throw new BadElementException("A pattern can not be used as a template to create an image.");
type = Element.IMGTEMPLATE;
scaledHeight = template.Height;
this.Top = scaledHeight;
scaledWidth = template.Width;
this.Right = scaledWidth;
TemplateData = template;
plainWidth = this.Width;
plainHeight = this.Height;
}
开发者ID:hjgode,项目名称:iTextSharpCF,代码行数:20,代码来源:ImgTemplate.cs
示例3: PdfFormXObject
/**
* Constructs a <CODE>PdfFormXObject</CODE>-object.
*
* @param template the template
* @param compressionLevel the compression level for the stream
* @since 2.1.3 (Replacing the existing constructor with param compressionLevel)
*/
internal PdfFormXObject(PdfTemplate template, int compressionLevel) : base() {
Put(PdfName.TYPE, PdfName.XOBJECT);
Put(PdfName.SUBTYPE, PdfName.FORM);
Put(PdfName.RESOURCES, template.Resources);
Put(PdfName.BBOX, new PdfRectangle(template.BoundingBox));
Put(PdfName.FORMTYPE, ONE);
PdfArray matrix = template.Matrix;
if (template.Layer != null)
Put(PdfName.OC, template.Layer.Ref);
if (template.Group != null)
Put(PdfName.GROUP, template.Group);
if (matrix == null)
Put(PdfName.MATRIX, MATRIX);
else
Put(PdfName.MATRIX, matrix);
bytes = template.ToPdf(null);
Put(PdfName.LENGTH, new PdfNumber(bytes.Length));
FlateCompress(compressionLevel);
}
开发者ID:,项目名称:,代码行数:27,代码来源:
示例4: FooterPdfInitialize
private static void FooterPdfInitialize(PdfWriter writer, Document document, PdfTemplate template, PdfContentByte contentByte, BaseFont baseFont, DateTime PrintTime)
{
int pageNumber = writer.PageNumber;
string footerText = string.Format("Strona {0}{1}", pageNumber, " z ");
float lenght = baseFont.GetWidthPoint(footerText, textSize);
Rectangle pageSize = document.PageSize;
contentByte.SetRGBColorFill(100, 100, 100);
contentByte.BeginText();
contentByte.SetFontAndSize(baseFont, textSize);
contentByte.SetTextMatrix(pageSize.GetLeft(left), pageSize.GetBottom(bottom));
contentByte.ShowText(footerText);
contentByte.EndText();
contentByte.AddTemplate(template, pageSize.GetLeft(left) + lenght, pageSize.GetBottom(bottom));
contentByte.BeginText();
contentByte.SetFontAndSize(baseFont, textSize);
contentByte.ShowTextAligned(PdfContentByte.ALIGN_RIGHT, string.Format("Utworzony: {0}", PrintTime.ToString()), pageSize.GetRight(right), pageSize.GetBottom(bottom), 0);
contentByte.EndText();
}
开发者ID:Khaleesy,项目名称:Csharp,代码行数:20,代码来源:PdfFooter.cs
示例5: AddTemplate
public void AddTemplate(PdfTemplate template, float x, float y, bool tagContent) {
AddTemplate(template, 1, 0, 0, 1, x, y, tagContent);
}
开发者ID:NelsonSantos,项目名称:fyiReporting-Android,代码行数:3,代码来源:PdfContentByte.cs
示例6: GetAppearance
/**
* Gets the main appearance layer.
* <p>
* Consult <A HREF="http://partners.adobe.com/asn/developer/pdfs/tn/PPKAppearances.pdf">PPKAppearances.pdf</A>
* for further details.
* @return the main appearance layer
* @throws DocumentException on error
*/
public PdfTemplate GetAppearance() {
if (IsInvisible()) {
PdfTemplate t = new PdfTemplate(writer);
t.BoundingBox = new Rectangle(0, 0);
writer.AddDirectTemplateSimple(t, null);
return t;
}
if (app[0] == null && !reuseAppearance)
CreateBlankN0();
if (app[1] == null && !acro6Layers) {
PdfTemplate t = app[1] = new PdfTemplate(writer);
t.BoundingBox = new Rectangle(100, 100);
writer.AddDirectTemplateSimple(t, new PdfName("n1"));
t.SetLiteral(questionMark);
}
if (app[2] == null) {
String text;
if (layer2Text == null) {
StringBuilder buf = new StringBuilder();
buf.Append("Digitally signed by ");
String name = null;
CertificateInfo.X509Name x500name = CertificateInfo.GetSubjectFields((X509Certificate)signCertificate);
if (x500name != null) {
name = x500name.GetField("CN");
if (name == null)
name = x500name.GetField("E");
}
if (name == null)
name = "";
buf.Append(name).Append('\n');
buf.Append("Date: ").Append(signDate.ToString("yyyy.MM.dd HH:mm:ss zzz"));
if (reason != null)
buf.Append('\n').Append(reasonCaption).Append(reason);
if (location != null)
buf.Append('\n').Append(locationCaption).Append(location);
text = buf.ToString();
}
else
text = layer2Text;
PdfTemplate t = app[2] = new PdfTemplate(writer);
t.BoundingBox = rect;
writer.AddDirectTemplateSimple(t, new PdfName("n2"));
if (image != null) {
if (imageScale == 0) {
t.AddImage(image, rect.Width, 0, 0, rect.Height, 0, 0);
}
else {
float usableScale = imageScale;
if (imageScale < 0)
usableScale = Math.Min(rect.Width / image.Width, rect.Height / image.Height);
float w = image.Width * usableScale;
float h = image.Height * usableScale;
float x = (rect.Width - w) / 2;
float y = (rect.Height - h) / 2;
t.AddImage(image, w, 0, 0, h, x, y);
}
}
Font font;
if (layer2Font == null)
font = new Font();
else
font = new Font(layer2Font);
float size = font.Size;
Rectangle dataRect = null;
Rectangle signatureRect = null;
if (renderingMode == RenderingMode.NAME_AND_DESCRIPTION ||
(renderingMode == RenderingMode.GRAPHIC_AND_DESCRIPTION && this.SignatureGraphic != null)) {
// origin is the bottom-left
signatureRect = new Rectangle(
MARGIN,
MARGIN,
rect.Width / 2 - MARGIN,
rect.Height - MARGIN);
dataRect = new Rectangle(
rect.Width / 2 + MARGIN / 2,
MARGIN,
rect.Width - MARGIN / 2,
rect.Height - MARGIN);
if (rect.Height > rect.Width) {
signatureRect = new Rectangle(
MARGIN,
rect.Height / 2,
rect.Width - MARGIN,
rect.Height);
dataRect = new Rectangle(
MARGIN,
MARGIN,
rect.Width - MARGIN,
rect.Height / 2 - MARGIN);
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:
示例7: AddDirectTemplateSimple
/**
* Adds a template to the document but not to the page resources.
* @param template the template to add
* @param forcedName the template name, rather than a generated one. Can be null
* @return the <CODE>PdfName</CODE> for this template
*/
internal PdfName AddDirectTemplateSimple(PdfTemplate template, PdfName forcedName) {
PdfIndirectReference refa = template.IndirectReference;
Object[] obj;
formXObjects.TryGetValue(refa, out obj);
PdfName name = null;
if (obj == null) {
if (forcedName == null) {
name = new PdfName("Xf" + formXObjectsCounter);
++formXObjectsCounter;
}
else
name = forcedName;
if (template.Type == PdfTemplate.TYPE_IMPORTED) {
// If we got here from PdfCopy we'll have to fill importedPages
PdfImportedPage ip = (PdfImportedPage)template;
PdfReader r = ip.PdfReaderInstance.Reader;
if (!readerInstances.ContainsKey(r)) {
readerInstances[r] = ip.PdfReaderInstance;
}
template = null;
}
formXObjects[refa] = new Object[]{name, template};
}
else
name = (PdfName)obj[0];
return name;
}
开发者ID:,项目名称:,代码行数:33,代码来源:
示例8: AddTemplate
/**
* Adds a template to this content.
*
* @param template the template
* @param x the x location of this template
* @param y the y location of this template
*/
public void AddTemplate(PdfTemplate template, float x, float y)
{
AddTemplate(template, 1, 0, 0, 1, x, y);
}
开发者ID:HardcoreSoftware,项目名称:iSecretary,代码行数:11,代码来源:PdfContentByte.cs
示例9: CheckNoPattern
/** Throws an error if it is a pattern.
* @param t the object to check
*/
internal void CheckNoPattern(PdfTemplate t)
{
if (t.Type == PdfTemplate.TYPE_PATTERN)
throw new ArgumentException(MessageLocalization.GetComposedMessage("invalid.use.of.a.pattern.a.template.was.expected"));
}
开发者ID:HardcoreSoftware,项目名称:iSecretary,代码行数:8,代码来源:PdfContentByte.cs
示例10: AddTemplate
/** Always throws an error. This operation is not allowed.
* @param template dummy
* @param a dummy
* @param b dummy
* @param c dummy
* @param d dummy
* @param e dummy
* @param f dummy */
public override void AddTemplate(PdfTemplate template, float a, float b, float c, float d, float e, float f) {
ThrowError();
}
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:11,代码来源:PdfImportedPage.cs
示例11: CreateTemplate
internal PdfTemplate CreateTemplate(float width, float height, PdfName forcedName)
{
CheckWriter();
PdfTemplate template = new PdfTemplate(writer);
template.Width = width;
template.Height = height;
writer.AddDirectTemplateSimple(template, forcedName);
return template;
}
开发者ID:HardcoreSoftware,项目名称:iSecretary,代码行数:9,代码来源:PdfContentByte.cs
示例12: GetInstance
/// <summary>
/// Gets an instance of an Image in raw mode.
/// </summary>
/// <param name="template"></param>
/// <returns></returns>
public static Image GetInstance(PdfTemplate template) {
return new ImgTemplate(template);
}
开发者ID:Gianluigi,项目名称:dssnet,代码行数:8,代码来源:Image.cs
示例13: CreateBlankN0
private void CreateBlankN0() {
PdfTemplate t = app[0] = new PdfTemplate(writer);
t.BoundingBox = new Rectangle(100, 100);
writer.AddDirectTemplateSimple(t, new PdfName("n0"));
t.SetLiteral("% DSBlank\n");
}
开发者ID:,项目名称:,代码行数:6,代码来源:
示例14: GetLayer
/**
* Gets a template layer to create a signature appearance. The layers can go from 0 to 4,
* but only layer 0 and 2 will be used if acro6Layers is true.
* <p>
* Consult <A HREF="http://partners.adobe.com/asn/developer/pdfs/tn/PPKAppearances.pdf">PPKAppearances.pdf</A>
* for further details.
* @param layer the layer
* @return a template
*/
public PdfTemplate GetLayer(int layer) {
if (layer < 0 || layer >= app.Length)
return null;
PdfTemplate t = app[layer];
if (t == null) {
t = app[layer] = new PdfTemplate(writer);
t.BoundingBox = rect;
writer.AddDirectTemplateSimple(t, new PdfName("n" + layer));
}
return t;
}
开发者ID:,项目名称:,代码行数:20,代码来源:
示例15: ReleaseTemplate
/**
* Releases the memory used by a template by writing it to the output. The template
* can still be added to any content but changes to the template itself won't have
* any effect.
* @param tp the template to release
* @throws IOException on error
*/
public void ReleaseTemplate(PdfTemplate tp) {
PdfIndirectReference refi = tp.IndirectReference;
Object[] objs;
formXObjects.TryGetValue(refi, out objs);
if (objs == null || objs[1] == null)
return;
PdfTemplate template = (PdfTemplate)objs[1];
if (template.IndirectReference is PRIndirectReference)
return;
if (template.Type == PdfTemplate.TYPE_TEMPLATE) {
AddToBody(template.GetFormXObject(compressionLevel), template.IndirectReference);
objs[1] = null;
}
}
开发者ID:,项目名称:,代码行数:21,代码来源:
示例16: GetTopLayer
/**
* Gets the template that aggregates all appearance layers. This corresponds to the /FRM resource.
* <p>
* Consult <A HREF="http://partners.adobe.com/asn/developer/pdfs/tn/PPKAppearances.pdf">PPKAppearances.pdf</A>
* for further details.
* @return the template that aggregates all appearance layers
*/
public PdfTemplate GetTopLayer() {
if (frm == null) {
frm = new PdfTemplate(writer);
frm.BoundingBox = rect;
writer.AddDirectTemplateSimple(frm, new PdfName("FRM"));
}
return frm;
}
开发者ID:,项目名称:,代码行数:15,代码来源:
示例17: OnOpenDocument
public override void OnOpenDocument(PdfWriter writer, Document document)
{
printTime = DateTime.Now;
string arialuniTff = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "ARIALUNI.TTF");
baseFont = BaseFont.CreateFont(arialuniTff, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
pdfContent = writer.DirectContent;
pageNumberTemplate = pdfContent.CreateTemplate(50, 50);
}
开发者ID:vamelnyk,项目名称:CorporateEmployeeServiceSystem,代码行数:8,代码来源:PrintHeaderFooter.cs
示例18: OnOpenDocument
public override void OnOpenDocument(PdfWriter writer, Document document)
{
total = writer.DirectContent.CreateTemplate(100, 100);
total.BoundingBox = new Rectangle(-20, -20, 100, 100);
helv = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
}
开发者ID:woofwoof88,项目名称:first-place-processing,代码行数:7,代码来源:pdfPrintEnvelopes.ashx.cs
示例19: OnOpenDocument
public override void OnOpenDocument(PdfWriter writer, Document document)
{
base.OnOpenDocument(writer, document);
font = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
dc = writer.DirectContent;
tpl = dc.CreateTemplate(50, 50);
}
开发者ID:stevesloka,项目名称:bvcms,代码行数:7,代码来源:EnrollmentControlResult.cs
示例20: OnOpenDocument
public override void OnOpenDocument(PdfWriter writer, Document document)
{
printTime = DateTime.Now;
baseFont = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
pdfContent = writer.DirectContent;
pageNumberTemplate = pdfContent.CreateTemplate(50, 50);
}
开发者ID:huutruongqnvn,项目名称:vnecoo01,代码行数:7,代码来源:PrintHeaderFooter.cs
注:本文中的iTextSharp.text.pdf.PdfTemplate类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论