本文整理匯總了C#中iTextSharp.text.pdf.PdfContentByte.SetFontAndSize方法的典型用法代碼示例。如果您正苦於以下問題:C# PdfContentByte.SetFontAndSize方法的具體用法?C# PdfContentByte.SetFontAndSize怎麽用?C# PdfContentByte.SetFontAndSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類iTextSharp.text.pdf.PdfContentByte
的用法示例。
在下文中一共展示了PdfContentByte.SetFontAndSize方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Draw
// ---------------------------------------------------------------------------
/**
* Draws a character representing an arrow at the current position.
* @see com.itextpdf.text.pdf.draw.VerticalPositionMark#draw(
* com.itextpdf.text.pdf.PdfContentByte, float, float, float, float, float)
*/
// i'm so stupid; originally forgot to override parent method and wondered
// why the arrows weren't being drawn...
public override void Draw(
PdfContentByte canvas, float llx, float lly, float urx, float ury, float y
) {
canvas.BeginText();
canvas.SetFontAndSize(zapfdingbats, 12);
if (left) {
canvas.ShowTextAligned(Element.ALIGN_CENTER,
((char) 220).ToString(), llx - 10, y, 0
);
}
else {
canvas.ShowTextAligned(Element.ALIGN_CENTER,
((char) 220).ToString(), urx + 10, y + 8, 180
);
}
canvas.EndText();
}
示例2: OnEndPage
public override void OnEndPage(PdfWriter writer, Document document)
{
base.OnEndPage(writer, document);
if (_isLastPage)
{
var relativeWidths = ColumnsHelper.GetRelativeColumnsForProducts(PageSize.A4);
//RODAPE
var pdfTableFooter = new BuilderTable().Create(relativeWidths).Standard();
pdfTableFooter.AddCell(new BuilderCell("", 5).Create("DADOS ADICIONAIS").FixedHeight(15).Bold().HorizontalLeft().VerticalBottom().Colspan(42).NoBorder().BorderBuilder(false, false, false, false).Standard());
pdfTableFooter.AddCell(new BuilderCell("", 5).Create("INFORMAÇÕES COMPLEMENTARES").FixedHeight(5).Bold().HorizontalLeft().VerticalTop().Colspan(32).NoBorder().BorderBuilder(true, true, false, true).Standard());
pdfTableFooter.AddCell(new BuilderCell("", 5).Create("RESERVADO AO FISCO").Bold().HorizontalLeft().VerticalTop().Colspan(10).NoBorder().BorderBuilder(true, true, false, true).Standard());
var infAdicional = _nfe.NFe.infNFe.infAdic;
pdfTableFooter.AddCell(new BuilderCell("", 5).Create(infAdicional.infCpl).FixedHeight(25).HorizontalLeft().VerticalTop().Colspan(32).NoBorder().BorderBuilder(true, true, false, false).Standard());
pdfTableFooter.AddCell(new BuilderCell("", 5).Create(" ").HorizontalLeft().VerticalTop().Colspan(10).NoBorder().BorderBuilder(true, true, false, false).Standard());
if (_isHomolog)
{
pdfTableFooter.AddCell(new BuilderCell("", 5).Create("SEM VALOR FISCAL").FixedHeight(5).HorizontalLeft().VerticalTop().Colspan(32).NoBorder().BorderBuilder(true, true, true, false).Standard());
pdfTableFooter.AddCell(new BuilderCell("", 5).Create(" ").HorizontalLeft().VerticalTop().Colspan(10).NoBorder().BorderBuilder(true, true, true, false).Standard());
}
document.Add(pdfTableFooter);
}
const float posX = 325f;
const float posY = 662f;
var pageN = writer.PageNumber;
var text = "Folha " + pageN + "/";
var len = _baseFont.GetWidthPoint(text, 8);
_pdfContent = writer.DirectContent;
_pdfContent.SetRGBColorFill(100, 100, 100);
_pdfContent.BeginText();
_pdfContent.SetFontAndSize(_baseFont, 8f);
_pdfContent.SetTextMatrix(posX, posY);
_pdfContent.ShowText(text);
_pdfContent.EndText();
_pdfContent.AddTemplate(_pageNumberTemplate, posX + len, posY);
_pdfContent.BeginText();
_pdfContent.SetFontAndSize(_baseFont, 8f);
_pdfContent.EndText();
}
示例3: AddWaterMarkText
private static void AddWaterMarkText(PdfContentByte directContent, string textWatermark, BaseFont font, float fontSize, float angle, BaseColor color, Rectangle realPageSize)
{
var gstate = new PdfGState { FillOpacity = 0.2f, StrokeOpacity = 0.2f };
directContent.SaveState();
directContent.SetGState(gstate);
directContent.SetColorFill(color);
directContent.BeginText();
directContent.SetFontAndSize(font, fontSize);
var x = (realPageSize.Right + realPageSize.Left) / 2;
var y = (realPageSize.Bottom + realPageSize.Top) / 2;
directContent.ShowTextAligned(Element.ALIGN_CENTER, textWatermark, x, y, angle);
directContent.EndText();
directContent.RestoreState();
}
示例4: ApplyForText
public void ApplyForText(PdfContentByte cb, IDictionary<String, String> css, Chunk chunk)
{
SetStrokeAndFillColor(cb, css);
SetStrokeAndFill(cb, css);
try
{
Font font = new Font(Font.FontFamily.COURIER, 6, Font.NORMAL, BaseColor.BLACK);
Font font2 = chunk.Font;
BaseFont bf2 = font2.BaseFont;
//BaseFont bf = ;
if (bf2 == null)
{
cb.SetFontAndSize(font.GetCalculatedBaseFont(false), font2.Size);
}
else
{
cb.SetFontAndSize(bf2, font2.Size);
}
} catch { }
}
示例5: PdfText
private static void PdfText(PdfContentByte cb, TextAlignedPdfConfig parms)
{
var bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
cb.SetColorFill(BaseColor.BLACK);
cb.SetFontAndSize(bf, 18);
cb.BeginText();
cb.ShowTextAligned(parms.Alignment, parms.Text, parms.X, parms.Y, parms.Rotation);
cb.EndText();
}
示例6: 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();
}
示例7: DrawInfo
// ---------------------------------------------------------------------------
/**
* Draws some text on every calendar sheet.
*
*/
protected void DrawInfo(PdfContentByte directcontent)
{
directcontent.BeginText();
directcontent.SetFontAndSize(bf, 18);
float x, y;
x = (OFFSET_LEFT + WIDTH + OFFSET_LOCATION) / 2;
y = OFFSET_BOTTOM + HEIGHT + 24;
directcontent.ShowTextAligned(
Element.ALIGN_CENTER,
"FOOBAR FILM FESTIVAL", x, y, 0
);
x = OFFSET_LOCATION + WIDTH_LOCATION / 2f - 6;
y = OFFSET_BOTTOM + HEIGHT_LOCATION;
directcontent.ShowTextAligned(
Element.ALIGN_CENTER,
"The Majestic", x, y, 90
);
y = OFFSET_BOTTOM + HEIGHT_LOCATION * 4f;
directcontent.ShowTextAligned(
Element.ALIGN_CENTER,
"Googolplex", x, y, 90
);
y = OFFSET_BOTTOM + HEIGHT_LOCATION * 7.5f;
directcontent.ShowTextAligned(
Element.ALIGN_CENTER,
"Cinema Paradiso", x, y, 90
);
directcontent.SetFontAndSize(bf, 12);
x = OFFSET_LOCATION + WIDTH_LOCATION - 6;
for (int i = 0; i < LOCATIONS; i++)
{
y = OFFSET_BOTTOM + ((8.5f - i) * HEIGHT_LOCATION);
directcontent.ShowTextAligned(
Element.ALIGN_CENTER,
locations[i], x, y, 90
);
}
directcontent.SetFontAndSize(bf, 6);
y = OFFSET_BOTTOM + HEIGHT + 1;
for (int i = 0; i < TIMESLOTS; i++)
{
x = OFFSET_LEFT + (i * WIDTH_TIMESLOT);
directcontent.ShowTextAligned(
Element.ALIGN_LEFT,
TIME[i], x, y, 45
);
}
directcontent.EndText();
}
示例8: OnEndPage
public override void OnEndPage(PdfWriter writer, Document document)
{
base.OnEndPage(writer, document);
int pageN = writer.PageNumber;
string text = "From SG Telecom SIGN.......................... Exe. Name "+ BusinessAccessLeyer.BAL.StaticVariables.selectuser+" Given To........................... ";
// string text = pageN + " - ";
float len = baseFont.GetWidthPoint(text, 8);
Rectangle pageSize = document.PageSize;
pdfContent = writer.DirectContent;
pdfContent.SetRGBColorFill(100, 100, 100);
pdfContent.BeginText();
pdfContent.SetFontAndSize(baseFont, 12);
// pdfContent.ShowTextAligned(PdfContentByte.ALIGN_LEFT, text, pageSize.GetRight(40), pageSize.GetBottom(30), 0);
pdfContent.ShowTextAligned(PdfContentByte.ALIGN_LEFT, text, pageSize.GetLeft(40) , pageSize.GetBottom(30), 0);
pdfContent.EndText();
BusinessAccessLeyer.BAL.StaticVariables.selectuser = "";
// string path = @"D:\Dropboxdata\Dropbox\mayankmvc\Web_Complete_Inv\PresantationAccessLeyer\Images\Address Img.jpg";
//// iTextSharp.text.Image instanceImg = iTextSharp.text.Image.GetInstance(path);
// //Image logo = Image.GetInstance(path);
// // logo.ScaleAbsolute(500, 300);
// string imageURL = path ; // Server.MapPath(".") + "/image2.jpg";
// iTextSharp.text.Image jpg = iTextSharp.text.Image.GetInstance(imageURL);
// //Resize image depend upon your need
// jpg.ScaleToFit(240f, 120f);
// //Give space before image
// jpg.SpacingBefore = 10f;
// //Give some space after the image
// jpg.SpacingAfter = 1f;
// //jpg.Alignment = Element.ALIGN_LEFT;
// jpg.Alignment = Element.ALIGN_CENTER;
// document.Add(jpg);
////////////////////////////////////
}
示例9: WriteLine
internal void WriteLine(PdfLine line, PdfContentByte text, PdfContentByte graphics) {
PdfFont currentFont = null;
foreach(PdfChunk chunk in line) {
if (chunk.Font.CompareTo(currentFont) != 0) {
currentFont = chunk.Font;
text.SetFontAndSize(currentFont.Font, currentFont.Size);
}
BaseColor color = chunk.Color;
if (color != null)
text.SetColorFill(color);
text.ShowText(chunk.ToString());
if (color != null)
text.ResetRGBColorFill();
}
}
示例10: Render_BackBase
private static void Render_BackBase(PdfContentByte under)
{
// Y relative to card top, line width, <repeat>
float[] measures = new[] { 37, 3f, 144, 1.5f };
under.SaveState();
for (int i = 0; i < measures.Length / 2; i++)
{
under.SetLineWidth(measures[i * 2 + 1]);
under.MoveTo(0, CARD_HEIGHT - measures[i * 2]);
under.LineTo(CARD_WIDTH, CARD_HEIGHT - measures[i * 2]);
under.Stroke();
}
under.SetFontAndSize(baseFont, 7);
under.ShowTextAlignedKerned(Element.ALIGN_CENTER, "If found, please call KCSAR at (206) 205-8226", CARD_WIDTH / 2, 7, 0);
under.RestoreState();
}
示例11: DrawBoxForCover
/// <summary>
/// Draws the box on the cover page that contains the date
/// </summary>
/// <param name="cb"></param>
/// <param name="doc"></param>
/// <param name="project"></param>
private void DrawBoxForCover(PdfContentByte cb, Document doc)
{
// set the colors
cb.SetColorStroke(_baseColor);
cb.SetColorFill(_baseColor);
// calculate the top left corner of the box
var x = doc.LeftMargin;
var y = doc.BottomMargin + 678;
var height = 60;
// move the cursor to starting position
cb.MoveTo(x, y);
// draw the top line
cb.LineTo(x + _pageWidth, y);
// draw the right line
cb.LineTo(x + _pageWidth, y - height);
// draw the bottom line
cb.LineTo(x, y - height);
// draw the left line
cb.LineTo(x, y);
cb.ClosePathFillStroke();
cb.Stroke();
// add the text inside the box
cb.BeginText();
cb.SetFontAndSize(_dateBaseFont, 26f);
cb.SetColorStroke(BaseColor.WHITE);
cb.SetColorFill(BaseColor.WHITE);
cb.SetTextMatrix(x + 10, y - 40);
cb.ShowText(string.Format("{0:MMMM dd, yyyy}", DateTime.Now));
cb.EndText();
}
示例12: WriteText
// This is the method writing text to the content byte
private static void WriteText(PdfContentByte cb, string text, int x, int y, int size, bool bold = false, int align = PdfContentByte.ALIGN_LEFT)
{
cb.SetFontAndSize(bold ? _baseFontBold : _baseFont, size);
cb.ShowTextAligned(align, text, x, y, 0);
}
示例13: WriteLine
internal void WriteLine(PdfLine line, PdfContentByte text, PdfContentByte graphics)
{
PdfFont currentFont = null;
foreach(PdfChunk chunk in line) {
if (chunk.Font.CompareTo(currentFont) != 0) {
currentFont = chunk.Font;
text.SetFontAndSize(currentFont.Font, currentFont.Size);
}
Object[] textRender = (Object[])chunk.GetAttribute(Chunk.TEXTRENDERMODE);
int tr = 0;
float strokeWidth = 1;
BaseColor color = chunk.Color;
BaseColor strokeColor = null;
if (textRender != null) {
tr = (int)textRender[0] & 3;
if (tr != PdfContentByte.TEXT_RENDER_MODE_FILL)
text.SetTextRenderingMode(tr);
if (tr == PdfContentByte.TEXT_RENDER_MODE_STROKE || tr == PdfContentByte.TEXT_RENDER_MODE_FILL_STROKE) {
strokeWidth = (float)textRender[1];
if (strokeWidth != 1)
text.SetLineWidth(strokeWidth);
strokeColor = (BaseColor)textRender[2];
if (strokeColor == null)
strokeColor = color;
if (strokeColor != null)
text.SetColorStroke(strokeColor);
}
}
object charSpace = chunk.GetAttribute(Chunk.CHAR_SPACING);
// no char space setting means "leave it as is".
if (charSpace != null && !curCharSpace.Equals(charSpace)) {
curCharSpace = (float)charSpace;
text.SetCharacterSpacing(curCharSpace);
}
if (color != null)
text.SetColorFill(color);
text.ShowText(chunk.ToString());
if (color != null)
text.ResetRGBColorFill();
if (tr != PdfContentByte.TEXT_RENDER_MODE_FILL)
text.SetTextRenderingMode(PdfContentByte.TEXT_RENDER_MODE_FILL);
if (strokeColor != null)
text.ResetRGBColorStroke();
if (strokeWidth != 1)
text.SetLineWidth(1);
}
}
示例14: WriteLine
internal void WriteLine(PdfLine line, PdfContentByte text, PdfContentByte graphics)
{
PdfFont currentFont = null;
foreach(PdfChunk chunk in line) {
if (chunk.Font.CompareTo(currentFont) != 0) {
currentFont = chunk.Font;
text.SetFontAndSize(currentFont.Font, currentFont.Size);
}
BaseColor color = chunk.Color;
object charSpace = chunk.GetAttribute(Chunk.CHAR_SPACING);
// no char space setting means "leave it as is".
if (charSpace != null && !curCharSpace.Equals(charSpace)) {
curCharSpace = (float)charSpace;
text.SetCharacterSpacing(curCharSpace);
}
if (color != null)
text.SetColorFill(color);
text.ShowText(chunk.ToString());
if (color != null)
text.ResetRGBColorFill();
}
}
示例15: PrintTerms
private MemoryStream PrintTerms(IEnumerable<GlossaryItem> terms)
{
float ppi = 72.0F;
float PageWidth = 8.5F;
float PageHeight = 11.0F;
float TopBottomMargin = 0.625F;
float LeftRightMargin = 0.75F;
float GutterWidth = 0.25F;
float HeaderFooterHeight = 0.125F;
float Column1Left = LeftRightMargin;
float Column1Right = ((PageWidth - (LeftRightMargin * 2) - GutterWidth) / 2) + LeftRightMargin;
float Column2Left = Column1Right + GutterWidth;
float Column2Right = PageWidth - LeftRightMargin;
bool HasMultipleDefinitions = (terms.Count() > 1);
string version = DataAccess.GetKeyValue("glossaryversion").Value;
Document doc = new Document(new Rectangle(0, 0, PageWidth * ppi, PageHeight * ppi));
MemoryStream m = new MemoryStream();
PdfWriter writer = PdfWriter.GetInstance(doc, m);
writer.CloseStream = false;
try {
doc.AddTitle("The Glossary of Systematic Christian Theology");
doc.AddSubject("A collection of technical terms and associated definitions as taught from the pulpit by Dr. Ron Killingsworth in classes at Rephidim Church.");
doc.AddCreator("My program using iText#");
doc.AddAuthor("Dr. Ron Killingsworth");
doc.AddCreationDate();
writer.SetEncryption(PdfWriter.STRENGTH128BITS, null, "xaris", PdfWriter.AllowCopy | PdfWriter.AllowPrinting | PdfWriter.AllowScreenReaders | PdfWriter.AllowDegradedPrinting);
doc.Open();
BaseFont bfArialBlack = BaseFont.CreateFont("C:\\windows\\fonts\\ariblk.ttf", BaseFont.WINANSI, false);
BaseFont bfGaramond = BaseFont.CreateFont("C:\\windows\\fonts\\gara.ttf", BaseFont.WINANSI, false);
Font fntTerm = new Font(bfArialBlack, 10, Font.BOLD, new BaseColor(57, 81, 145));
Font fntDefinition = new Font(bfGaramond, 9, Font.NORMAL, new BaseColor(0, 0, 0));
///////////////////////////////////////////
if (HasMultipleDefinitions) {
PdfContentByte cbCover = new PdfContentByte(writer);
cbCover = writer.DirectContent;
cbCover.BeginText();
cbCover.SetFontAndSize(bfGaramond, 42);
cbCover.SetRGBColorFill(57, 81, 145);
cbCover.ShowTextAligned(PdfContentByte.ALIGN_CENTER, "Glossary of", (PageWidth / 2) * ppi, ((PageHeight / 2) + Convert.ToSingle(1.5)) * ppi, 0);
cbCover.ShowTextAligned(PdfContentByte.ALIGN_CENTER, "Systematic Christian Theology", (PageWidth / 2) * ppi, ((PageHeight / 2) + 1) * ppi, 0);
cbCover.SetFontAndSize(bfGaramond, 16);
cbCover.SetRGBColorFill(0, 0, 0);
cbCover.ShowTextAligned(PdfContentByte.ALIGN_CENTER, "A collection of technical terms and associated definitions", (PageWidth / 2) * ppi, ((PageHeight / 2) + Convert.ToSingle(0.6)) * ppi, 0);
cbCover.ShowTextAligned(PdfContentByte.ALIGN_CENTER, "as taught by Dr. Ron Killingsworth, Rephidim Church, Wichita Falls, Texas", (PageWidth / 2) * ppi, ((PageHeight / 2) + Convert.ToSingle(0.4)) * ppi, 0);
cbCover.SetFontAndSize(bfGaramond, 12);
cbCover.SetRGBColorFill(0, 0, 0);
cbCover.ShowTextAligned(PdfContentByte.ALIGN_CENTER, "Published by:", (PageWidth / 2) * ppi, ((PageHeight / 2) - Convert.ToSingle(0.6)) * ppi, 0);
cbCover.ShowTextAligned(PdfContentByte.ALIGN_CENTER, "Rephidim Doctrinal Bible Studies, Inc.", (PageWidth / 2) * ppi, ((PageHeight / 2) - Convert.ToSingle(0.8)) * ppi, 0);
cbCover.ShowTextAligned(PdfContentByte.ALIGN_CENTER, "4430 Allendale Rd., Wichita Falls, Texas 76310", (PageWidth / 2) * ppi, ((PageHeight / 2) - Convert.ToSingle(1.0)) * ppi, 0);
cbCover.ShowTextAligned(PdfContentByte.ALIGN_CENTER, "(940) 691-1166 rephidim.org [email protected]", (PageWidth / 2) * ppi, ((PageHeight / 2) - Convert.ToSingle(1.2)) * ppi, 0);
cbCover.SetFontAndSize(bfGaramond, 10);
cbCover.SetRGBColorFill(0, 0, 0);
cbCover.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "Version: " + version + " / " + terms.Count() + " terms", (LeftRightMargin) * ppi, (TopBottomMargin) * ppi, 0);
cbCover.SetFontAndSize(bfGaramond, 10);
cbCover.SetRGBColorFill(0, 0, 0);
cbCover.ShowTextAligned(PdfContentByte.ALIGN_RIGHT, "© 1971-" + DateTime.Today.Year.ToString() + " Dr. Ron Killingsworth, Rephidim Doctrinal Bible Studies, Inc.", (PageWidth - LeftRightMargin) * ppi, (TopBottomMargin) * ppi, 0);
cbCover.EndText();
doc.NewPage();
///////////////////////////////////////////
PdfContentByte cbBlank = new PdfContentByte(writer);
cbBlank = writer.DirectContent;
cbBlank.BeginText();
cbCover.SetFontAndSize(bfGaramond, 10);
cbCover.SetRGBColorFill(0, 0, 0);
cbCover.ShowTextAligned(PdfContentByte.ALIGN_LEFT, " ", (LeftRightMargin) * ppi, (TopBottomMargin) * ppi, 0);
cbBlank.EndText();
doc.NewPage();
///////////////////////////////////////////
}
PdfContentByte cb = writer.DirectContent;
ColumnText ct = new ColumnText(cb);
//.........這裏部分代碼省略.........