C# 使用 PDFsharp 的表格和图表

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1102485/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 08:18:12  来源:igfitidea点击:

Tables and charts using PDFsharp

c#chartspdf-generationpdfsharp

提问by David Bo?jak

I just started with a project that requires me to write to PDF file. After some googling I decided on using PDFsharp which looks simple enough, however I have a few questions regarding drawing tables and charts.

我刚刚开始了一个需要我写入 PDF 文件的项目。经过一番谷歌搜索后,我决定使用看起来很简单的 PDFsharp,但是我有一些关于绘制表格和图表的问题。

Is PDFsharp a good choice for writing PDF files that contain tables and charts? If no, can you recommend a better alternative? If yes, where could I find some good literature on the subject? A tutorial would be nice (doesn't have to be a sample project, just something I can use to familiarise myself with the library and its classes).

PDFsharp 是编写包含表格和图表的 PDF 文件的好选择吗?如果不是,你能推荐一个更好的选择吗?如果是,我在哪里可以找到关于这个主题的一些好的文献?教程会很好(不必是示例项目,只是我可以用来熟悉库及其类的东西)。

Can anyone tell me what MigraDoc is all about? I just took a glimpse and it seems perfect for what I need, however I would like some more information about it.

谁能告诉我 MigraDoc 是什么?我只是瞥了一眼,它似乎非常适合我的需要,但是我想了解更多有关它的信息。

采纳答案by I liked the old Stack Overflow

PDFsharp is a "low level" PDF generator, while MigraDoc is a "high level" document generator that uses PDFsharp to create PDF files, but can also create e. g. RTF.

PDFsharp 是一个“低级”PDF 生成器,而 MigraDoc 是一个“高级”文档生成器,它使用 PDFsharp 创建 PDF 文件,但也可以创建例如 RTF。

Visit the PDFsharp/MigraDoc Foundation Website for further information:
http://www.pdfsharp.net/

访问 PDFsharp/MigraDoc 基金会网站了解更多信息:http://www.pdfsharp.net/

回答by bnu

If you dont want to use MigraDoc, you can use the gfx.Drawline() and draw the table yourself. I did it in one of my Projects. You can do it like that:

如果不想使用 MigraDoc,可以使用 gfx.Drawline() 自己绘制表格。我在我的一个项目中做到了。你可以这样做:

        gfx.DrawLine(pen, 45, 250, 45, 703);
        gfx.DrawLine(pen, 87, 250, 87, 703);
        gfx.DrawLine(pen, 150, 250, 150, 703);
        gfx.DrawLine(pen, 291, 250, 291, 703);
        gfx.DrawLine(pen, 381, 250, 381, 703);
        gfx.DrawLine(pen, 461, 250, 461, 703);
        gfx.DrawLine(pen, 571, 250, 571, 703);

Or you can use a for loop to do it like that and count the postion up.

或者您可以使用 for 循环来执行此操作并计算位置。