用于无头 Linux 服务器的 C# PDF 库
我目前正在尝试找到一个无需运行 X 服务器即可运行的 PDF 库。我已经尝试过以下...
- Migradoc/PDFSharp(需要 X)
- ITextSharp(需要 X)
- SharpPDF(可能有用,但我正在寻找具有更多功能的东西)
该库没有开源或免费。
我的解决方案在 Apache2.2 mod_mono 上运行。
有人知道这样的图书馆吗?
--- 编辑 ---
下面列出了用于 itextsharp 的测试代码,它在我的测试服务器上产生错误(Migradoc 和 SharpPDF 的代码也很简单):
using System;
using sharp=iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.xml;
using System.IO;
namespace pdftester
{
public static class ITextSharpTest
{
public static void HelloWorld(string filename)
{
Stream stream = new FileStream(filename, FileMode.Create);
sharp.Document document = new sharp.Document();
PdfWriter.GetInstance(document, stream);
document.Open();
document.Add(new sharp.Paragraph("Hello world"));
document.Close();
}
}
}
I'm currently trying to find a PDF library which will run without a running X server. I have already tried the following...
- Migradoc/PDFSharp (requires X)
- ITextSharp (requires X)
- SharpPDF (might work, but I am looking for something with a bit more features)
The library does not have to be opensource or free.
My solution runs on Apache2.2 mod_mono.
Does anyone know of such library?
--- edit ---
The test code used for itextsharp, which produces errors on my testserver is listed below (the code for Migradoc and SharpPDF is just as simple):
using System;
using sharp=iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.xml;
using System.IO;
namespace pdftester
{
public static class ITextSharpTest
{
public static void HelloWorld(string filename)
{
Stream stream = new FileStream(filename, FileMode.Create);
sharp.Document document = new sharp.Document();
PdfWriter.GetInstance(document, stream);
document.Open();
document.Add(new sharp.Paragraph("Hello world"));
document.Close();
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于没有人对这个帖子给出明确的答案,所以我将关闭它。
我选择采用 SharpPDF 方式,因为它是我的服务器上唯一支持的方式。我只需要实现我的项目所需的内容即可。
感谢迄今为止收到的帮助:)
Since no one has given a definitive answer to the thread, i'm closing it.
I've chosen to go the sharpPDF way, as it's the only one supported on my server. I'll simply have to implement what's needed for my project.
Thanks for the help received so far :)