-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathProgram.cs
More file actions
27 lines (24 loc) · 830 Bytes
/
Program.cs
File metadata and controls
27 lines (24 loc) · 830 Bytes
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
using System.IO;
using CSharpMath.VectSharp;
using VectSharp;
using VectSharp.PDF;
using VectSharp.SVG;
var painter = new TextPainter {
LaTeX = @"Let's render some math to a PDF and an SVG file!$$x = {-b \pm \color{red}\sqrt{b^2-4ac} \over 2a}$$"
};
var page = painter.DrawToPage(400f); // adjust width here
var doc = new Document { Pages = { page } };
// PDF
var tempFileName = Path.Combine(Path.GetTempPath(), "CSharpMath.pdf");
doc.SaveAsPDF(tempFileName);
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo {
FileName = tempFileName,
UseShellExecute = true
});
// SVG
tempFileName = Path.Combine(Path.GetTempPath(), "CSharpMath.svg");
page.SaveAsSVG(tempFileName);
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo {
FileName = tempFileName,
UseShellExecute = true
});