我是 c#、wpf 和 pdfsharp 库的新手。这是我的 XAML 代码:
<Grid>
<zoom:ZoomControl>
<graphsharp:GraphLayout x:Name="graphLayout"
Graph="{Binding ElementName=root, Path=GraphToVisualize}"
LayoutAlgorithmType="FR"
OverlapRemovalAlgorithmType="FSA"
HighlightAlgorithmType="Simple"></graphsharp:GraphLayout>
</zoom:ZoomControl>
<Button Content="Button" Height="23" Name="button1" Width="75" Margin="12,294,658,412" Click="button1_Click" />
</Grid>
我现在想使用 Pdfsharp 将我的“graphLayout”保存到 pdf 文件中。我创建了一个按钮并基本上使用 pdfsharp wiki 中的“hello world”示例代码来启动。
PdfDocument document = new PdfDocument();
document.Info.Title = "Created with PDFsharp";
PdfPage page = document.AddPage();
XGraphics gfx = XGraphics.FromPdfPage(page);
XFont font = new XFont("Verdana", 20, XFontStyle.BoldItalic);
gfx.DrawString("My Graph", font, XBrushes.Black,
new XRect(0, 0, page.Width, page.Height),
XStringFormats.TopCenter);
const string filename = "MyGraph.pdf";
document.Save(graphLayout+filename);
Process.Start(filename);
我得到一个 pdf ,但里面只有文字。有人可以告诉我,我如何将整个布局保存为pdf?谢谢