本文整理匯總了C#中PdfSharp.Drawing.XGraphicsPath.AddString方法的典型用法代碼示例。如果您正苦於以下問題:C# XGraphicsPath.AddString方法的具體用法?C# XGraphicsPath.AddString怎麽用?C# XGraphicsPath.AddString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PdfSharp.Drawing.XGraphicsPath
的用法示例。
在下文中一共展示了XGraphicsPath.AddString方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: RenderPage
public override void RenderPage(XGraphics gfx)
{
base.RenderPage(gfx);
#if true__
XPen pen = new XPen(XColors.DarkGreen, 20);
gfx.DrawLine(pen, 0, 0, 1000, 1000);
#endif
XGraphicsPath path = new XGraphicsPath();
path.AddString("@", new XFontFamily("Times New Roman"), XFontStyle.BoldItalic, 500, new XPoint(90, 60), XStringFormats.Default);
gfx.DrawPath(properties.Pen2.Pen, properties.Brush2.Brush, path);
}
示例2: RenderGlyphsPath
void RenderGlyphsPath(XGraphics gfx)
{
gfx.TranslateTransform(15, 20);
XGraphicsPath path = new XGraphicsPath();
//path.AddString("Hello!", new XFontFamily("Times New Roman"), XFontStyle.BoldItalic, 100, new XRect(0, 0, 250, 140),
// XStringFormat.Center);
path.AddString("Hello!", new XFontFamily("Times New Roman"), XFontStyle.BoldItalic, 100, new XRect(0, 0, 250, 140), XStringFormats.Center);
gfx.DrawPath(new XPen(XColors.Purple, 2.3), XBrushes.DarkOrchid, path);
}
示例3: RenderClipPath
void RenderClipPath(XGraphics gfx)
{
gfx.TranslateTransform(15, 20);
XGraphicsPath path = new XGraphicsPath();
path.AddString("Clip!", new XFontFamily("Verdana"), XFontStyle.Bold, 90, new XRect(0, 0, 250, 140),
XStringFormats.Center);
gfx.IntersectClip(path);
gfx.DrawRectangle(XBrushes.LightSalmon, new XRect(0, 0, 10000, 10000));
// Draw a beam of dotted lines
XPen pen = XPens.DarkRed.Clone();
pen.DashStyle = XDashStyle.Dot;
for (double r = 0; r <= 90; r += 0.5)
gfx.DrawLine(pen, 0, 0, 1000 * Math.Cos(r / 90 * Math.PI), 1000 * Math.Sin(r / 90 * Math.PI));
}
示例4: RenderPage
public override void RenderPage(XGraphics gfx)
{
base.RenderPage(gfx);
// Create a new graphical path
XGraphicsPath path = new XGraphicsPath();
// Add the outline of the glyphs of the word 'Clip' to the path
path.AddString("Clip!", new XFontFamily("Times New Roman"), XFontStyle.BoldItalic, 250, new XPoint(30, 100), XStringFormats.Default);
#if DEBUG_
gfx.WriteComment("SetClip");
#endif
// Set the path as clip path
gfx.IntersectClip(path);
#if DEBUG_
gfx.WriteComment("Random lines");
#endif
// Draw some random lines to show that clipping happens
Random rnd = new Random(42);
for (int idx = 0; idx < 300; idx++)
gfx.DrawLine(properties.Pen2.Pen, rnd.Next(600), rnd.Next(500), rnd.Next(600), rnd.Next(500));
}
示例5: Main
static void Main()
{
const string watermark = "PDFsharp";
const int emSize = 150;
// Get a fresh copy of the sample PDF file
const string filename = "Portable Document Format.pdf";
File.Copy(Path.Combine("../../../../../PDFs/", filename),
Path.Combine(Directory.GetCurrentDirectory(), filename), true);
// Create the font for drawing the watermark
XFont font = new XFont("Times New Roman", emSize, XFontStyle.BoldItalic);
// Open an existing document for editing and loop through its pages
PdfDocument document = PdfReader.Open(filename);
// Set version to PDF 1.4 (Acrobat 5) because we use transparency.
if (document.Version < 14)
document.Version = 14;
for (int idx = 0; idx < document.Pages.Count; idx++)
{
//if (idx == 1) break;
PdfPage page = document.Pages[idx];
switch (idx % 3)
{
case 0:
{
// Variation 1: Draw watermark as text string
// Get an XGraphics object for drawing beneath the existing content
XGraphics gfx = XGraphics.FromPdfPage(page, XGraphicsPdfPageOptions.Prepend);
#if true_
// Fill background with linear gradient color
XRect rect = page.MediaBox.ToXRect();
XLinearGradientBrush gbrush = new XLinearGradientBrush(rect,
XColors.LightSalmon, XColors.WhiteSmoke, XLinearGradientMode.Vertical);
gfx.DrawRectangle(gbrush, rect);
#endif
// Get the size (in point) of the text
XSize size = gfx.MeasureString(watermark, font);
// Define a rotation transformation at the center of the page
gfx.TranslateTransform(page.Width / 2, page.Height / 2);
gfx.RotateTransform(-Math.Atan(page.Height / page.Width) * 180 / Math.PI);
gfx.TranslateTransform(-page.Width / 2, -page.Height / 2);
// Create a string format
XStringFormat format = new XStringFormat();
format.Alignment = XStringAlignment.Near;
format.LineAlignment = XLineAlignment.Near;
// Create a dimmed red brush
XBrush brush = new XSolidBrush(XColor.FromArgb(128, 255, 0, 0));
// Draw the string
gfx.DrawString(watermark, font, brush,
new XPoint((page.Width - size.Width) / 2, (page.Height - size.Height) / 2),
format);
}
break;
case 1:
{
// Variation 2: Draw watermark as outlined graphical path
// Get an XGraphics object for drawing beneath the existing content
XGraphics gfx = XGraphics.FromPdfPage(page, XGraphicsPdfPageOptions.Prepend);
// Get the size (in point) of the text
XSize size = gfx.MeasureString(watermark, font);
// Define a rotation transformation at the center of the page
gfx.TranslateTransform(page.Width / 2, page.Height / 2);
gfx.RotateTransform(-Math.Atan(page.Height / page.Width) * 180 / Math.PI);
gfx.TranslateTransform(-page.Width / 2, -page.Height / 2);
// Create a graphical path
XGraphicsPath path = new XGraphicsPath();
// Add the text to the path
path.AddString(watermark, font.FontFamily, XFontStyle.BoldItalic, 150,
new XPoint((page.Width - size.Width) / 2, (page.Height - size.Height) / 2),
XStringFormats.Default);
// Create a dimmed red pen
XPen pen = new XPen(XColor.FromArgb(128, 255, 0, 0), 2);
// Stroke the outline of the path
gfx.DrawPath(pen, path);
}
break;
case 2:
{
// Variation 3: Draw watermark as transparent graphical path above text
//.........這裏部分代碼省略.........
示例6: DrawClipPath
/// <summary>
/// Clips through path.
/// </summary>
void DrawClipPath(XGraphics gfx, int number)
{
BeginBox(gfx, number, "Clip through Path");
XGraphicsPath path = new XGraphicsPath();
path.AddString("Clip!", new XFontFamily("Verdana"), XFontStyle.Bold, 90, new XRect(0, 0, 250, 140),
XStringFormats.Center);
gfx.IntersectClip(path);
// Draw a beam of dotted lines
XPen pen = XPens.DarkRed.Clone();
pen.DashStyle = XDashStyle.Dot;
for (double r = 0; r <= 90; r += 0.5)
gfx.DrawLine(pen, 0, 0, 250 * Math.Cos(r / 90 * Math.PI), 250 * Math.Sin(r / 90 * Math.PI));
EndBox(gfx);
}
示例7: DrawGlyphs
/// <summary>
/// Converts text to path.
/// </summary>
void DrawGlyphs(XGraphics gfx, int number)
{
BeginBox(gfx, number, "Draw Glyphs");
XGraphicsPath path = new XGraphicsPath();
path.AddString("Hello!", new XFontFamily("Times New Roman"), XFontStyle.BoldItalic, 100, new XRect(0, 0, 250, 140),
XStringFormats.Center);
gfx.DrawPath(new XPen(XColors.Purple, 2.3), XBrushes.DarkOrchid, path);
EndBox(gfx);
}
示例8: DrawText
static void DrawText(XGraphics gfx, XPen pen, XBrush brush)
{
XSize size = gfx.PageSize;
XGraphicsPath path = new XGraphicsPath();
path.AddString("PDFsharp",
new XFontFamily("Verdana"), XFontStyle.BoldItalic, 60,
new XRect(0, size.Height / 3.5, size.Width, 0), XStringFormats.Center);
gfx.DrawPath(new XPen(pen.Color, 3), brush, path);
}
示例9: AddWaterMark
public void AddWaterMark(PdfPage page, string watermark, XFont font)
{
// Get an XGraphics object for drawing beneath the existing content
using (XGraphics gfx = XGraphics.FromPdfPage(page, XGraphicsPdfPageOptions.Append))
{
// Get the size (in point) of the text
XSize size = gfx.MeasureString(watermark, font);
// Define a rotation transformation at the center of the page
double w = page.Width;
double h = page.Height;
if (page.Rotate == 90)
{
w = page.Height;
h = page.Width;
}
gfx.TranslateTransform(w / 2, h / 2);
gfx.RotateTransform(-Math.Atan(h / w) * 180 / Math.PI);
gfx.TranslateTransform(-w / 2, -h / 2);
// Create a graphical path
XGraphicsPath path = new XGraphicsPath();
// Add the text to the path
path.AddString(watermark, font.FontFamily, XFontStyle.BoldItalic, 48,
new XPoint((w - size.Width) / 2, (h - size.Height) / 2),
XStringFormats.Default);
// Create a dimmed red pen and brush
XPen pen = new XPen(XColor.FromArgb(50, 0, 0, 0), 1);
XBrush brush = new XSolidBrush(XColor.FromArgb(128, 201, 235, 143));
// Stroke the outline of the path
gfx.DrawPath(pen, brush, path);
}
}