本文整理匯總了C#中iTextSharp.text.pdf.PdfContentByte.Stroke方法的典型用法代碼示例。如果您正苦於以下問題:C# PdfContentByte.Stroke方法的具體用法?C# PdfContentByte.Stroke怎麽用?C# PdfContentByte.Stroke使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類iTextSharp.text.pdf.PdfContentByte
的用法示例。
在下文中一共展示了PdfContentByte.Stroke方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: DrawTimeTable
// ---------------------------------------------------------------------------
/**
* Draws the time table for a day at the film festival.
* @param directcontent a canvas to which the time table has to be drawn.
*/
protected void DrawTimeTable(PdfContentByte directcontent)
{
directcontent.SaveState();
directcontent.SetLineWidth(1.2f);
float llx, lly, urx, ury;
llx = OFFSET_LEFT;
lly = OFFSET_BOTTOM;
urx = OFFSET_LEFT + WIDTH;
ury = OFFSET_BOTTOM + HEIGHT;
directcontent.MoveTo(llx, lly);
directcontent.LineTo(urx, lly);
directcontent.LineTo(urx, ury);
directcontent.LineTo(llx, ury);
directcontent.ClosePath();
directcontent.Stroke();
llx = OFFSET_LOCATION;
lly = OFFSET_BOTTOM;
urx = OFFSET_LOCATION + WIDTH_LOCATION;
ury = OFFSET_BOTTOM + HEIGHT;
directcontent.MoveTo(llx, lly);
directcontent.LineTo(urx, lly);
directcontent.LineTo(urx, ury);
directcontent.LineTo(llx, ury);
directcontent.ClosePathStroke();
directcontent.SetLineWidth(1);
directcontent.MoveTo(
OFFSET_LOCATION + WIDTH_LOCATION / 2, OFFSET_BOTTOM
);
directcontent.LineTo(
OFFSET_LOCATION + WIDTH_LOCATION / 2, OFFSET_BOTTOM + HEIGHT
);
float y;
for (int i = 1; i < LOCATIONS; i++)
{
y = OFFSET_BOTTOM + (i * HEIGHT_LOCATION);
if (i == 2 || i == 6)
{
directcontent.MoveTo(OFFSET_LOCATION, y);
directcontent.LineTo(OFFSET_LOCATION + WIDTH_LOCATION, y);
}
else
{
directcontent.MoveTo(OFFSET_LOCATION + WIDTH_LOCATION / 2, y);
directcontent.LineTo(OFFSET_LOCATION + WIDTH_LOCATION, y);
}
directcontent.MoveTo(OFFSET_LEFT, y);
directcontent.LineTo(OFFSET_LEFT + WIDTH, y);
}
directcontent.Stroke();
directcontent.RestoreState();
}
示例2: 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;
}
示例3: DrawLine
public void DrawLine(
PdfContentByte cb, float x1, float x2, float y
)
{
cb.MoveTo(x1, y);
cb.LineTo(x2, y);
cb.Stroke();
}
示例4: HeaderPdfInitialize
private static void HeaderPdfInitialize(PdfWriter writer, Document document, string headerText, byte[] byteArray, PdfContentByte contentByte)
{
Phrase text = TextOfHeader(headerText);
iTextSharp.text.Image image = ImageOfHeader(byteArray);
TableOfHeader(document, image, text).WriteSelectedRows(0, -1, 10, document.PageSize.Height - 10, writer.DirectContent);
contentByte = writer.DirectContent;
contentByte.LineTo(document.PageSize.Width - 40, document.PageSize.Height - 35);
contentByte.Stroke();
}
示例5: DirectDrawReport
private void DirectDrawReport(PdfContentByte canvas)
{
//畫線
canvas.SaveState();
canvas.SetLineWidth(2f);
canvas.MoveTo(100, 100);
canvas.LineTo(200, 200);
canvas.Stroke();
canvas.RestoreState();
//文本
ColumnText.ShowTextAligned(canvas, Element.ALIGN_RIGHT, new Phrase("JulyLuo測試", new Font(BF_Light, 10)), 100, 20, 0);
}
示例6: DrawBlock
// ---------------------------------------------------------------------------
/**
* Draws a colored block on the time table, corresponding with
* the screening of a specific movie.
* @param screening a screening POJO, contains a movie and a category
* @param under the canvas to which the block is drawn
*/
protected void DrawBlock(
Screening screening, PdfContentByte under, PdfContentByte over
) {
under.SaveState();
BaseColor color = WebColors.GetRGBColor(
"#" + screening.movie.entry.category.color
);
under.SetColorFill(color);
Rectangle rect = GetPosition(screening);
under.Rectangle(
rect.Left, rect.Bottom, rect.Width, rect.Height
);
under.Fill();
over.Rectangle(
rect.Left, rect.Bottom, rect.Width, rect.Height
);
over.Stroke();
under.RestoreState();
}
示例7: 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();
}
示例8: Render
/// <summary>
/// Renders the object in a document using a <see cref="PdfContentByte"/> by invoking the <see cref="Render(ContentWriter, Vector2D)"/> method.
/// This method can be overridden in derived classes to specify rendering.
/// </summary>
/// <param name="cb">The <see cref="PdfContentByte"/> used for rendering.</param>
/// <param name="offset">The calculated offset for the rendered item.</param>
protected internal virtual void Render(PdfContentByte cb, Vector2D offset)
{
using (var writer = new ContentWriter(cb))
{
var stroke = this as StrokeObject;
var fill = this as FillObject;
bool hasstroke = stroke?.BorderColor.HasValue ?? false;
bool hasfill = fill?.FillColor.HasValue ?? false;
if (hasstroke)
{
cb.SetLineWidth((float)stroke.BorderWidth.Value(UnitsOfMeasure.Points));
cb.SetColorStroke(new Color(stroke.BorderColor.Value));
}
if (hasfill)
cb.SetColorFill(new Color(fill.FillColor.Value));
Render(writer, offset);
if (hasstroke && hasfill)
{
if (writer.CloseShape)
cb.ClosePathFillStroke();
else
cb.FillStroke();
}
else if (hasstroke)
{
if (writer.CloseShape)
cb.ClosePathStroke();
else
cb.Stroke();
}
else if (hasfill)
cb.Fill();
}
}
示例9: Close
public bool Close(PdfContentByte cb, float fontSize, float xtlm, float ytlm)
{
if (_isPrevEmDash)
{
var padding = fontSize * _emDashPaddingRatio;
cb.LineTo(xtlm, ytlm + padding);
cb.Stroke();
cb.BeginText();
_isPrevEmDash = false;
return true;
}
else
{
return false;
}
}
示例10: DrawLine
/**
* Draws a horizontal line.
* @param canvas the canvas to draw on
* @param leftX the left x coordinate
* @param rightX the right x coordindate
* @param y the y coordinate
*/
public void DrawLine(PdfContentByte canvas, float leftX, float rightX, float y)
{
float w;
if (Percentage < 0)
w = -Percentage;
else
w = (rightX - leftX) * Percentage / 100.0f;
float s;
switch (Alignment) {
case Element.ALIGN_LEFT:
s = 0;
break;
case Element.ALIGN_RIGHT:
s = rightX - leftX - w;
break;
default:
s = (rightX - leftX - w) / 2;
break;
}
canvas.SetLineWidth(LineWidth);
if (LineColor != null)
canvas.SetColorStroke(LineColor);
canvas.MoveTo(s + leftX, y + offset);
canvas.LineTo(s + w + leftX, y + offset);
canvas.Stroke();
}
示例11: RenderPurchaseOrder
public void RenderPurchaseOrder(Stream stream, int PoNumber, IEnumerable<PoItemModel> PoItems, int RequestNumber, string VendorName, string VendorCode, string VendorAddress, DateTime DateCreated, DateTime DeliveryDate, UserModel RequestUser, UserModel CurrentUser)
{
Document document = new Document(PageSize.LETTER);
try {
PdfWriter writer = PdfWriter.GetInstance(document, stream);
document.Open();
// Create a page in the document and add it to the bottom layer
document.NewPage();
//Pass Document to this
CurrentDoc = document;
string logoLocation = sonicLogo;
float logoPosition = 50;
string CurrentCompany = RequestUser.CompanyName;
//Image
if (RequestUser.CompanyId == (int)CompanyIds.SonicSteel) {
logoLocation = sonicLogo;
logoPosition = 70;
}
else if (RequestUser.CompanyId == (int)CompanyIds.SteelTech) {
logoLocation = steeltechLogo;
}
else if (RequestUser.CompanyId == (int)CompanyIds.Somico) {
logoLocation = somicoLogo;
}
Image logo = Image.GetInstance(Directory.GetCurrentDirectory() + logoLocation);
logo.SetAbsolutePosition(20, (int)CurrentDoc.GetTop(logoPosition));
// START HERE ----------------------------
Paragraph Grid = new Paragraph("\n\n\n\n\n\n\n\n\n");
Grid.Alignment = 1;
Grid.SpacingAfter = 35f;
document.Add(Grid);
Paragraph Grid2 = new Paragraph();
Grid2.Alignment = 1;
Grid2.SpacingBefore = 35f;
//Start Table -----------------------------------
PdfPTable rightTable = new PdfPTable(7);
int[] widths = { 1, 1, 1, 7, 2, 2, 2 };
rightTable.SetWidths(widths);
rightTable.TotalWidth = 570f;
rightTable.LockedWidth = true;
Font tableFont = new Font(Font.FontFamily.HELVETICA, 8);
rightTable.HorizontalAlignment = Element.ALIGN_CENTER;
rightTable.AddCell(new Phrase("Item No.", tableFont));
rightTable.AddCell(new Phrase("Quantity", tableFont));
rightTable.AddCell(new Phrase("UOM", tableFont));
rightTable.AddCell(new Phrase("Item Description", tableFont));
rightTable.AddCell(new Phrase("Unit Price", tableFont));
rightTable.AddCell(new Phrase("Discount", tableFont));
rightTable.AddCell(new Phrase("Total Amount", tableFont));
rightTable.HorizontalAlignment = Element.ALIGN_LEFT;
int itemCount = 1;
foreach (var poItem in PoItems) {
rightTable.AddCell(new Phrase(itemCount.ToString(), tableFont)); rightTable.AddCell(new Phrase(poItem.Quantity.ToString(), tableFont)); rightTable.AddCell(new Phrase(poItem.UOM, tableFont)); rightTable.AddCell(new Phrase(poItem.Description, tableFont)); rightTable.AddCell(new Phrase(poItem.Price.ToString(), tableFont)); rightTable.AddCell(new Phrase(poItem.Discount.ToString(), tableFont)); rightTable.AddCell(new Phrase(poItem.TotalPrice.ToString(), tableFont));
itemCount++;
}
//Nothing Follows
rightTable.AddCell(new Phrase("", tableFont)); rightTable.AddCell(new Phrase("", tableFont)); rightTable.AddCell(new Phrase("")); rightTable.AddCell(new Phrase("******** NOTHING FOLLOWS ********", tableFont)); rightTable.AddCell(new Phrase("")); rightTable.AddCell(new Phrase("")); rightTable.AddCell(new Phrase(""));
//Grand Total
rightTable.AddCell(new Phrase("", tableFont)); rightTable.AddCell(new Phrase("", tableFont)); rightTable.AddCell(new Phrase("")); rightTable.AddCell(new Phrase("", tableFont)); rightTable.AddCell(new Phrase("")); rightTable.AddCell(new Phrase("Grand Total:", new Font(Font.FontFamily.HELVETICA, 12))); rightTable.AddCell(new Phrase(PoItems.Sum(x => x.TotalPrice).ToString(), new Font(Font.FontFamily.HELVETICA, 12)));
Grid2.Add(rightTable);
document.Add(Grid2);
// End of table -----------------------------------
page = writer.DirectContentUnder;
page.AddImage(logo);
page.Stroke();
// For "Purchase Order" Text
PrintRectangle(20, 120, 570, 50);
//For two tables
PrintRectangle(20, 230, 350, 100);
PrintRectangle(370, 230, 220, 100);
//For Footer
PrintRectangleBottom(20, 20, 570, 50);
page.BeginText();
SetFontSizeTo(24);
PrintText("PURCHASE ORDER", 180, 105);
SetPOCompanyHeader(RequestUser);
SetFontSizeTo(10);
// Header
PrintText("To:", 25, 140); // Vendor Name
SetFontSizeTo(8);
//.........這裏部分代碼省略.........
示例12: 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();
}
示例13: PrintTerms
//.........這裏部分代碼省略.........
PdfContentByte cb = writer.DirectContent;
ColumnText ct = new ColumnText(cb);
int[] left = {
Convert.ToInt32(Column1Left * ppi),
Convert.ToInt32(Column2Left * ppi)
};
int[] right = {
Convert.ToInt32(Column1Right * ppi),
Convert.ToInt32(Column2Right * ppi)
};
foreach (var term in terms) {
ct.AddText(new Phrase(term.Term.Trim() + Environment.NewLine, fntTerm));
ct.AddText(new Phrase(Regex.Replace(term.Definition.Trim().Replace("<br/>", "\r"), @"<[^>]+>", "") + Environment.NewLine + Environment.NewLine, fntDefinition));
}
int status = 0;
int column = 0;
int PageNumber = 0;
if (HasMultipleDefinitions) {
PageNumber = 3;
} else {
PageNumber = 1;
}
while ((status & ColumnText.NO_MORE_TEXT) == 0) {
///////////////////////////////////////////
PdfContentByte cbPage = new PdfContentByte(writer);
cbPage = writer.DirectContent;
cbPage.SetLineWidth(0.5f);
cbPage.SetRGBColorStroke(50, 50, 50);
cbPage.MoveTo(LeftRightMargin * ppi, (PageHeight - TopBottomMargin - (HeaderFooterHeight / 2)) * ppi);
cbPage.LineTo((PageWidth - LeftRightMargin) * ppi, (PageHeight - TopBottomMargin - (HeaderFooterHeight / 2)) * ppi);
cbPage.Stroke();
cbPage.SetLineWidth(0.5f);
cbPage.SetRGBColorStroke(50, 50, 50);
cbPage.MoveTo(LeftRightMargin * ppi, (TopBottomMargin + HeaderFooterHeight) * ppi);
cbPage.LineTo((PageWidth - LeftRightMargin) * ppi, (TopBottomMargin + HeaderFooterHeight) * ppi);
cbPage.Stroke();
cbPage.BeginText();
cbPage.SetFontAndSize(bfGaramond, 10);
cbPage.SetRGBColorFill(0, 0, 0);
cbPage.ShowTextAligned(PdfContentByte.ALIGN_CENTER, "The Glossary of Systematic Christian Theology", (PageWidth / 2) * ppi, (PageHeight - TopBottomMargin) * ppi, 0);
if (PageNumber % 2 == 0) {
cbPage.SetFontAndSize(bfGaramond, 8);
cbPage.SetRGBColorFill(0, 0, 0);
cbPage.ShowTextAligned(PdfContentByte.ALIGN_RIGHT, "© 1971-" + DateTime.Today.Year.ToString() + " Dr. Ron Killingsworth, Rephidim Doctrinal Bible Studies, Inc.", (PageWidth - LeftRightMargin) * ppi, (TopBottomMargin) * ppi, 0);
cbPage.SetFontAndSize(bfGaramond, 8);
cbPage.SetRGBColorFill(0, 0, 0);
cbPage.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "Page " + PageNumber.ToString(), (LeftRightMargin) * ppi, (TopBottomMargin) * ppi, 0);
} else {
cbPage.SetFontAndSize(bfGaramond, 8);
cbPage.SetRGBColorFill(0, 0, 0);
cbPage.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "© 1971-" + DateTime.Today.Year.ToString() + " Dr. Ron Killingsworth, Rephidim Doctrinal Bible Studies, Inc.", (LeftRightMargin) * ppi, (TopBottomMargin) * ppi, 0);
cbPage.SetFontAndSize(bfGaramond, 8);
cbPage.SetRGBColorFill(0, 0, 0);
cbPage.ShowTextAligned(PdfContentByte.ALIGN_RIGHT, "Page " + PageNumber.ToString(), (PageWidth - LeftRightMargin) * ppi, (TopBottomMargin) * ppi, 0);
示例14: PictureBackdrop
// ---------------------------------------------------------------------------
/**
* Prints a square and fills half of it with a gray rectangle.
*
* @param x
* @param y
* @param cb
* @throws Exception
*/
public static void PictureBackdrop(float x, float y, PdfContentByte cb) {
cb.SetColorStroke(GrayColor.GRAYBLACK);
cb.SetColorFill(new GrayColor(0.8f));
cb.Rectangle(x, y, 100, 200);
cb.Fill();
cb.SetLineWidth(2);
cb.Rectangle(x, y, 200, 200);
cb.Stroke();
}
示例15: Close
public void Close(PdfContentByte cb, IDictionary<String, String> css)
{
//default is true for both
String fillValue;
String strokeValue;
bool fill = (!css.TryGetValue("fill", out fillValue) || fillValue == null || !fillValue.Equals("none"));
bool stroke = (!css.TryGetValue("stroke", out strokeValue) || strokeValue == null || !strokeValue.Equals("none"));
if (fill && stroke) {
cb.FillStroke();
} else if (fill) {
cb.Fill();
} else if (stroke) {
cb.Stroke();
}
}