用于无头 Linux 服务器的 C# PDF 库

发布于 2024-09-14 20:02:23 字数 960 浏览 0 评论 0原文

我目前正在尝试找到一个无需运行 X 服务器即可运行的 PDF 库。我已经尝试过以下...

  1. Migradoc/PDFSharp(需要 X)
  2. ITextSharp(需要 X)
  3. 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...

  1. Migradoc/PDFSharp (requires X)
  2. ITextSharp (requires X)
  3. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

演出会有结束 2024-09-21 20:02:23

由于没有人对这个帖子给出明确的答案,所以我将关闭它。

我选择采用 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 :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文