-
Notifications
You must be signed in to change notification settings - Fork 0
/
PdfFeatures.cs
38 lines (27 loc) · 1.07 KB
/
PdfFeatures.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using PdfSharp.Drawing;
using PdfSharp.Drawing.Layout;
using PdfSharp.Pdf;
namespace CatalogPdf
{
internal class PdfFeatures
{
public void AddSpaceDoc(string path, string name, string description)
{
string fullname = path + @"\" + name + ".pdf";
PdfDocument document = new PdfDocument();
PdfPage page = document.AddPage();
XGraphics gfx = XGraphics.FromPdfPage(page);
XFont fontTitle = new XFont("Verdana", 16, XFontStyle.Bold);
XFont font = new XFont("Verdana", 14, XFontStyle.Regular);
// Draw the text
gfx.DrawString(name, fontTitle, XBrushes.Black,
new XRect(40, 20, page.Width - 40, 100),
XStringFormats.Center);
XRect rect = new XRect(40, 120, page.Width - 20, page.Height);
XTextFormatter tf = new XTextFormatter(gfx);
tf.DrawString(description, font, XBrushes.Black, rect, XStringFormats.TopLeft);
document.Save(fullname);
document.Dispose();
}
}
}