forked from ststeiger/PdfSharpCore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
58 lines (38 loc) · 1.54 KB
/
Program.cs
File metadata and controls
58 lines (38 loc) · 1.54 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
namespace SampleApp
{
public class Program
{
private static string GetOutFilePath(string name)
{
string OutputDirName = @".";
return System.IO.Path.Combine(OutputDirName, name);
}
private static void SaveDocument(PdfSharpCore.Pdf.PdfDocument document, string name)
{
string outFilePath = GetOutFilePath(name);
string? dir = System.IO.Path.GetDirectoryName(outFilePath);
if (dir != null && !System.IO.Directory.Exists(dir))
{
System.IO.Directory.CreateDirectory(dir);
}
document.Save(outFilePath);
}
public static void Main(string[] args)
{
System.Console.WriteLine("Starting...");
const string outName = "test1.pdf";
PdfSharpCore.Pdf.PdfDocument? document = new PdfSharpCore.Pdf.PdfDocument();
PdfSharpCore.Pdf.PdfPage? pageNewRenderer = document.AddPage();
PdfSharpCore.Drawing.XGraphics? renderer = PdfSharpCore.Drawing.XGraphics.FromPdfPage(pageNewRenderer);
renderer.DrawString(
"Testy Test Test"
, new PdfSharpCore.Drawing.XFont("Arial", 12)
, PdfSharpCore.Drawing.XBrushes.Black
, new PdfSharpCore.Drawing.XPoint(12, 12)
);
SaveDocument(document, outName);
System.Console.WriteLine("Done!");
} // End Sub Main
} // End Class Program
} // End Namespace SampleApp