本文整理匯總了C#中iTextSharp.text.pdf.PdfContentByte.CreateTemplate方法的典型用法代碼示例。如果您正苦於以下問題:C# PdfContentByte.CreateTemplate方法的具體用法?C# PdfContentByte.CreateTemplate怎麽用?C# PdfContentByte.CreateTemplate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類iTextSharp.text.pdf.PdfContentByte
的用法示例。
在下文中一共展示了PdfContentByte.CreateTemplate方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: 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);
}
示例2: 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);
}
示例3: CheckmarkImage
/// <summary>
/// A vector checkmark image's definition
/// </summary>
/// <param name="contentByte">drawing canvas</param>
/// <param name="color">fill color</param>
/// <returns>a vector image</returns>
public static Image CheckmarkImage(PdfContentByte contentByte, System.Drawing.Color color)
{
var template = contentByte.CreateTemplate(260, 260);
template.MoveTo(38.33889376f, 67.35513328f);
template.CurveTo(39.90689547f, 67.35509017f, 41.09296342f, 66.03921993f, 41.89711165f, 63.40748424f);
template.CurveTo(43.50531445f, 58.47289182f, 44.65118131f, 56.00562195f, 45.33470755f, 56.0056459f);
template.CurveTo(45.85735449f, 56.00562195f, 46.40013944f, 56.41682961f, 46.96305772f, 57.23928802f);
template.CurveTo(58.2608517f, 75.74384316f, 68.7143666f, 90.71198997f, 78.32362116f, 102.14379168f);
template.CurveTo(80.81631349f, 105.10443984f, 84.77658911f, 106.58480942f, 90.20445269f, 106.58489085f);
template.CurveTo(91.49097185f, 106.58480942f, 92.35539361f, 106.46145048f, 92.79773204f, 106.21480444f);
template.CurveTo(93.23991593f, 105.96799555f, 93.4610547f, 105.65958382f, 93.46113432f, 105.28956447f);
template.CurveTo(93.4610547f, 104.71379041f, 92.7976618f, 103.58294901f, 91.47094155f, 101.89705463f);
template.CurveTo(75.95141033f, 82.81670149f, 61.55772504f, 62.66726353f, 48.28984822f, 41.44869669f);
template.CurveTo(47.36506862f, 39.96831273f, 45.47540199f, 39.22812555f, 42.62081088f, 39.22813992f);
template.CurveTo(39.72597184f, 39.22812555f, 38.0172148f, 39.35149407f, 37.49457722f, 39.5982407f);
template.CurveTo(36.12755286f, 40.2150402f, 34.51931728f, 43.36081778f, 32.66987047f, 49.03557823f);
template.CurveTo(30.57914689f, 55.32711903f, 29.53378743f, 59.27475848f, 29.53381085f, 60.87852533f);
template.CurveTo(29.53378743f, 62.60558406f, 30.94099884f, 64.27099685f, 33.75542165f, 65.87476369f);
template.CurveTo(35.48425582f, 66.86164481f, 37.01207517f, 67.35509017f, 38.33889376f, 67.35513328f);
template.SetRGBColorFill(color.R, color.G, color.B);
template.Fill();
var img = Image.GetInstance(template);
return img;
}
示例4: Draw
protected override void Draw(PdfContentByte cb)
{
//TODO if width and height not know: what to do
//PdfTemplate template = cb.CreateTemplate(this.width, this.height);
PdfTemplate template = cb.CreateTemplate(500, 500);
//draw the list of elements on the new template
foreach (IElement elem in this.list)
{
Graphic graphic = (Graphic)elem;
if (applyCSSToElements)
{
graphic.Draw(template, GetCombinedCss(graphic.GetCss(), GetCss()));
}
else
{
graphic.Draw(template, graphic.GetCss());
}
}
//add the template at the x, y position
System.Drawing.Drawing2D.Matrix translation = new System.Drawing.Drawing2D.Matrix();
translation.Translate(this.x, this.y);
cb.ConcatCTM(translation);
cb.Add(template);
}
示例5: 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);
}
示例6: PdfFooter
private static PdfTemplate PdfFooter(PdfContentByte cb)
{
// Create the template and assign height
PdfTemplate tmpFooter = cb.CreateTemplate(580, 70);
// Move to the bottom left corner of the template
tmpFooter.MoveTo(1, 1);
// Place the footer content
tmpFooter.Stroke();
// Begin writing the footer
tmpFooter.BeginText();
// Set the font and size
tmpFooter.SetFontAndSize(_baseFont, 8);
// Write out details from the payee table
tmpFooter.ShowTextAligned(PdfContentByte.ALIGN_CENTER, "De facturen zijn contant betaalbaar te Tielt of op rekeningnummer", cb.PdfWriter.PageSize.Width / 2, 45, 0);
tmpFooter.ShowTextAligned(PdfContentByte.ALIGN_CENTER, "733-0318587-69 bij KBC of 001-6090654-03 bij BNP Paribas Fortis", cb.PdfWriter.PageSize.Width / 2, 35, 0);
tmpFooter.ShowTextAligned(PdfContentByte.ALIGN_CENTER, "Alle klachten dienen binnen de 24 uren, na de uitgevoerde werken schriftelijk medegedeeld te worden.", cb.PdfWriter.PageSize.Width / 2, 25, 0);
tmpFooter.ShowTextAligned(PdfContentByte.ALIGN_CENTER, "Bij geschillen is enkel de rechtbank van Brugge bevoegd.", cb.PdfWriter.PageSize.Width / 2, 15, 0);
// End text
tmpFooter.EndText();
// Stamp a line above the page footer
cb.SetLineWidth(0f);
cb.MoveTo(30, 60);
cb.LineTo(570, 60);
cb.Stroke();
// Return the footer template
return tmpFooter;
}
示例7: CrossImage
/// <summary>
/// A vector cross sign image's definition
/// </summary>
/// <param name="cb">drawing canvas</param>
/// <param name="color">fill color</param>
/// <returns>a vector image</returns>
public static Image CrossImage(PdfContentByte cb, System.Drawing.Color color)
{
var template = cb.CreateTemplate(240, 240);
template.NewPath();
template.MoveTo(13.57143f, 76.42857262f);
template.LineTo(23.57143f, 86.42857262f);
template.LineTo(48.57143f, 61.42857262f);
template.LineTo(73.57143f, 86.42857262f);
template.LineTo(83.57143f, 76.42857262f);
template.LineTo(58.57143f, 51.42857262f);
template.LineTo(83.57143f, 26.42857262f);
template.LineTo(73.57143f, 16.42857262f);
template.LineTo(48.57143f, 41.42857262f);
template.LineTo(23.57143f, 16.42857262f);
template.LineTo(13.57143f, 26.42857262f);
template.LineTo(38.57143f, 51.42857262f);
template.ClosePath();
template.NewPath();
template.MoveTo(13.57143f, 76.42857262f);
template.LineTo(23.57143f, 86.42857262f);
template.LineTo(48.57143f, 61.42857262f);
template.LineTo(73.57143f, 86.42857262f);
template.LineTo(83.57143f, 76.42857262f);
template.LineTo(58.57143f, 51.42857262f);
template.LineTo(83.57143f, 26.42857262f);
template.LineTo(73.57143f, 16.42857262f);
template.LineTo(48.57143f, 41.42857262f);
template.LineTo(23.57143f, 16.42857262f);
template.LineTo(13.57143f, 26.42857262f);
template.LineTo(38.57143f, 51.42857262f);
template.ClosePath();
template.NewPath();
template.MoveTo(13.57143f, 76.42857262f);
template.LineTo(23.57143f, 86.42857262f);
template.LineTo(48.57143f, 61.42857262f);
template.LineTo(73.57143f, 86.42857262f);
template.LineTo(83.57143f, 76.42857262f);
template.LineTo(58.57143f, 51.42857262f);
template.LineTo(83.57143f, 26.42857262f);
template.LineTo(73.57143f, 16.42857262f);
template.LineTo(48.57143f, 41.42857262f);
template.LineTo(23.57143f, 16.42857262f);
template.LineTo(13.57143f, 26.42857262f);
template.LineTo(38.57143f, 51.42857262f);
template.ClosePath();
template.SetRGBColorFill(color.R, color.G, color.B);
template.Fill();
var img = Image.GetInstance(template);
return img;
}
示例8: PdfGraphics
internal PdfGraphics(string filename, int width, int height)
{
originalWidth = currentWidth = width;
originalHeight = currentHeight = height;
document = new Document(new iTextSharp.text.Rectangle(width, height), 50, 50, 50, 50);
document.AddAuthor("");
document.AddSubject("");
try{
writer = PdfWriter.GetInstance(document, new FileStream(filename, FileMode.Create));
document.Open();
content = writer.DirectContent;
template = topTemplate = content.CreateTemplate(width, height);
content.AddTemplate(template, 0, 0);
} catch (DocumentException de){
throw new IOException(de.Message);
}
}
示例9: PdfGraphics
public PdfGraphics(Stream stream, int width, int height)
{
originalWidth = currentWidth = width;
originalHeight = currentHeight = height;
document = new Document(new Rectangle(width, height), 50, 50, 50, 50);
document.AddAuthor("");
document.AddSubject("");
try{
writer = PdfWriter.GetInstance(document, stream);
document.Open();
content = writer.DirectContent;
template = topTemplate = content.CreateTemplate(width, height);
content.AddTemplate(template, 0, 0);
} catch (DocumentException de){
throw new IOException(de.Message);
}
}
示例10: CreateTemplate
// ---------------------------------------------------------------------------
/**
* Creates a template based on a stream of PDF syntax.
* @param content The direct content
* @param rect The dimension of the templare
* @param factor A magnification factor
* @return A PdfTemplate
*/
public virtual PdfTemplate CreateTemplate(
PdfContentByte content, Rectangle rect, int factor)
{
PdfTemplate template = content.CreateTemplate(rect.Width, rect.Height);
template.ConcatCTM(factor, 0, 0, factor, 0, 0);
string hero = Path.Combine(Utility.ResourceText, "hero.txt");
if (!File.Exists(hero)) {
throw new ArgumentException(hero + " NOT FOUND!");
}
var fi = new FileInfo(hero);
using ( var sr = fi.OpenText() ) {
while (sr.Peek() >= 0) {
template.SetLiteral((char) sr.Read());
}
}
return template;
}
示例11: OnOpenDocument
public override void OnOpenDocument(PdfWriter writer, Document document)
{
try
{
PrintTime = DateTime.Now;
baseFont = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
contentByte = writer.DirectContent;
template = contentByte.CreateTemplate(50, 50);
}
catch (DocumentException de)
{
Console.WriteLine("||On OpenDocument||" + de.StackTrace);
}
catch (System.IO.IOException ioe)
{
Console.WriteLine("||On OpenDocument||" + ioe.StackTrace);
}
}
示例12: OnOpenDocument
public override void OnOpenDocument(PdfWriter writer, Document document)
{
try
{
_printTime = DateTime.Now;
_bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
_cb = writer.DirectContent;
_template = _cb.CreateTemplate(50, 50);
}
catch (DocumentException de)
{
}
catch (System.IO.IOException ioe)
{
}
}
示例13: OnOpenDocument
public void OnOpenDocument(PdfWriter writer, Document document)
{
_pageSize = document.PageSize;
_pdfContent = writer.DirectContent;
_pdfTemplate = _pdfContent.CreateTemplate(50, 50);
}
示例14: OnOpenDocument
public override void OnOpenDocument(PdfWriter writer, Document document)
{
try
{
PrintTime = DateTime.Now;
bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
cb = writer.DirectContent;
headerTemplate = cb.CreateTemplate(100, 100);
footerTemplate = cb.CreateTemplate(50, 50);
}
catch (DocumentException de)
{
//handle exception here
}
catch (System.IO.IOException ioe)
{
//handle exception here
}
}
示例15: OnOpenDocument
public override void OnOpenDocument(PdfWriter writer, Document document)
{
cb = writer.DirectContent;
template = cb.CreateTemplate(50, 50);
base.OnOpenDocument(writer, document);
}