产品比较

IronPDF与Docraptor——全面比较

发布 2022年三月22日
分享:

1.导言

如果您希望将 HTML 网站转换为其他格式,那就来对地方了。 本文将讨论如何将 HTML、CSS 和 JS 转换为 PDF。 如今,一切都以技术为基础,而这些技术的设计者需要省时的解决方案--使用最常用的编程语言之一,.NET 的 C#。 在 C# 中,处理 PDF 文件并对其进行操作的传统方法既复杂又耗时。 PDF 文件最常见的用途是

  • PDF渲染
  • 将 HTML 转换为 PDF

    人们开发了许多工具来处理这些 PDF 转换和出现的任何问题。本文将比较开发人员最推崇的两个用于 PDF 转换的 C# 库。 相关工具如下:

  • 医生猛禽
  • IronPDF

2.IronPDF

IronPDF 是.NET 和 .NET Core 开发中 HTML 网站转换的梦想工具。 它不仅能转换 HTML,还能提供许多其他功能。 在 .NET Core 和 Framework 项目中,IronPDF 允许开发人员生成、修改和提取 PDF 文档。 开发人员可以使用 IronPDF 库从 HTML 文档快速创建或转换 PDF。

IronPDF for .NET 允许您自动读取 PDF 文件中的信息,并将其注入到您的 .NET 应用程序和数据存储系统中。 可将旧 PDF 文档存储中的内容导入、迁移到文档管理和业务流程应用程序中并编制索引。

2.1.IronPDF 功能

__2.1.1.PDF 转换___

该功能包括从 HTML、HTML 字符串、MVC 视图、Web 表单和 URL 等不同格式创建 PDF。

__2.1.2.PDF 成像___

这样,用户就可以从 PDF 文件创建图像,并 创建 PDF 从图像。 它包括图像提取、支持不同的图像扩展名和 PDF 打印。

2.1.3.PDF 文件 IO

IronPDF 还为 PDF 提供 128 位加密、用密码锁定 PDF 和数字签名 PDF 等功能。

__2.1.4.编辑 PDF 文件___

IronPDF 的这一功能提供所有类型的 PDF 格式化,如添加水印、添加页面、删除页面、背景、前景等。 简而言之,IronPDF 提供了您能想到的与 PDF 有关的所有功能。

__2.1.5.PDF 内容提取___

在许多情况下,您可以直接从 PDF 中提取嵌入的文本。 如果这不起作用,你的阅读器很可能实际上嵌入了一张图片。 使用 IronOCR 库扫描文档的视觉文本,而不是纯文本。

__2.1.6.页眉和页脚___

创建 PDF 时可添加页眉和页脚,也可添加到现有 PDF 中。 打印选项 "属性允许您为每个文档页面制作页眉和页脚。 访问 Chrome PDF 渲染器对象上的这些选项。 该示例在 .NET Core 控制台应用程序中运行。

__2.1.7.兼容性___

IronPDF 支持几乎所有与 C# 兼容的操作系统和框架,如:C#:

  • 支持Windows, Azure
    • .NET Core 2.1、3.0、3.1、.NET 6 & 5
      • 符合 .NET 标准 2.0,实现通用兼容性
      • 天蓝色
        • AWS
        • Docker
        • Linux

3.医生猛禽

DocRaptor 是一款专业的文档转换解决方案,但与 IronPDF 不同的是,它为多种编程词典提供的功能有限。 它是一个基于 API 的工具,可以与任何语言集成。 它质量高、速度快,可为你节省时间。它还提供将 XML 文件转换为 XLSX 的功能。

DocRaptor 可为您托管文件。 它支持 CSS 和 JS。 对于不拥有自己服务器的小型企业来说,这些都是极好的功能。

3.1.DocRaptor 功能

__3.1.1.HTML 到 PDF 的生成___

DocRaptor 可将 HTML、CSS 和 JS 快速直接地转换为 PDF 和 XLS 文档。 只需将 HTML 内容和所需参数以表单编码文本或 JSON 对象的形式发布到 Docs API。

3.1.2 HTML 转换为 Excel 格式___

许多报告和数据导出都需要 PDF 和 Excel 的支持。 DocRaptor基于HTML的工具让这一切变得简单!

__3.1.3.文件托管___

文件将保存在无品牌的 URL 上,任何人都可以从任何地方访问。 您可以无限期地保留它,也可以在某个日期或下载量之后将其删除。

注:

根据从 NuGet 在网站上,IronPDF 比 DocRaptor 更受欢迎,总下载量为 3.0 M,日平均下载量为 1.3 K。 另一方面,DocRaptor 的总下载量仅为 114.9 K,平均每天下载 51 次。

4.在 Visual Studio 中创建新项目

打开 Visual Studio 软件,进入 "文件 "菜单。 选择 "新项目",然后选择控制台应用程序。 在本文中,我们将使用控制台应用程序生成 PDF 文档。

在相应文本框中输入项目名称并选择路径。 然后,点击创建按钮。 选择所需的 .NET Framework,如下图所示:

Visual Studio 项目现在将为所选应用程序生成结构,如果您选择了控制台、Windows 和 Web 应用程序,它将打开 program.cs 文件,您可以在其中输入代码并构建/运行应用程序。

现在我们可以添加库并测试程序了。

5.安装 IronPDF 库

IronPDF 库可以通过四种不同的方式下载和安装。 它们是

  • 使用 Visual Studio NuGet 软件包管理器
  • 使用 Visual Studio 命令行
  • 从 NuGet 网页直接下载。
  • 从 IronPDF 网页直接下载。

5.1 使用 Visual Studio NuGet 软件包管理器

Visual Studio 软件提供了 NuGet 软件包管理器选项,可直接将软件包安装到解决方案中。 下面的截图显示了如何打开 NuGet 包管理器。

它提供了一个搜索框,显示 NuGet 网站上可用的软件包库列表。在软件包管理器中,我们需要搜索关键字 "IronPDF",如下图所示:

从上图中,我们将看到相关软件包的搜索列表。我们需要选择 IronPDF 选项并安装该软件包。

5.2 使用 Visual Studio 命令行

  • 在 Visual Studio 菜单中,转到工具-> NuGet 包管理器-> 包管理器控制台
  • 在软件包管理器控制台选项卡中输入以下一行:
Install-Package IronPdf

现在,软件包将下载/安装到当前项目,并可随时使用。

5.3 从 NuGet 网页直接下载

第三种方法是直接从网页上下载 NuGet 软件包。

  • 导航至链接"https://www.nuget.org/packages/IronPdf/"
  • 从右侧菜单中选择下载软件包选项。
  • 双击下载的软件包; 就会自动安装。
  • 现在重新加载解决方案,并开始在项目中使用。

5.4 从 IronPDF 网页直接下载

点击 链接 在此直接从网页下载最新软件包。 下载完成后,请按照以下步骤将软件包添加到项目中。

  • 右键单击解决方案窗口中的项目。
  • 然后,选择参考文献选项,再浏览下载参考文献的位置。
  • 然后,单击 "确定 "添加引用。

6.安装 DocRaptor API

DocRaptor 团队提供了几乎所有相同的集成 API 的方法。 它们是

  • 使用 Visual Studio NuGet 软件包管理器
  • 使用 Visual Studio NuGet 软件包控制台。
  • 使用 Visual Studio 命令行
  • 从 NuGet 网站直接下载。

6.1 使用 Visual Studio NuGet 软件包管理器

与之前对 IronPDF 的解释一样,打开 NuGet 包管理器的步骤也是一样的。

打开软件包管理器后,只需在搜索栏中写入 DocRaptor 即可。

如上图所示,DocRaptor 有三个结果。 选择所需的选项。

6.2.使用 Visual studio NuGet 软件包控制台

在 Visual Studio 菜单中,转到工具-> NuGet 包管理器->包管理器控制台。 在软件包管理器控制台选项卡中输入以下一行:install-Package DocRaptor。 现在,软件包将下载/安装到当前项目,并可随时使用。

6.3.从 NuGet 网站直接下载。

第三种方法是直接从网页上下载 NuGet 软件包。

  • 导航至链接"https://www.nuget.org/packages/DocRaptor/".
  • 从右侧菜单中选择下载软件包选项。
  • 双击下载的软件包; 它将自动安装。
  • 接下来,重新加载解决方案并开始在项目中使用。

7.从 HTML 制作 PDF

这两种工具都包含 HTML 转换功能,只是转换方式略有不同。

7.1.使用 IronPDF 从 HTML 制作 PDF

使用 IronPDF 转换页面不需要使用 JSON 和加密技术,其实非常简单。 IronPDF 允许多种不同的方法。 例如

  • 将 HTML 文件转换为 PDF
var Renderer = new IronPdf.ChromePdfRenderer();
Renderer.RenderHtmlAsPdf("<h1>Html with CSS and Images</h1>").SaveAs("pixel-perfect.pdf");
var Renderer = new IronPdf.ChromePdfRenderer();
Renderer.RenderHtmlAsPdf("<h1>Html with CSS and Images</h1>").SaveAs("pixel-perfect.pdf");
Dim Renderer = New IronPdf.ChromePdfRenderer()
Renderer.RenderHtmlAsPdf("<h1>Html with CSS and Images</h1>").SaveAs("pixel-perfect.pdf")
VB   C#
  • URL 到 PDF
IronPdf.ChromePdfRenderer Renderer = new IronPdf.ChromePdfRenderer();
var Pdf = Renderer.RenderUrlAsPdf("https://ironpdf.com/");
Pdf.SaveAs("url.pdf"); 
IronPdf.ChromePdfRenderer Renderer = new IronPdf.ChromePdfRenderer();
var Pdf = Renderer.RenderUrlAsPdf("https://ironpdf.com/");
Pdf.SaveAs("url.pdf"); 
Dim Renderer As New IronPdf.ChromePdfRenderer()
Dim Pdf = Renderer.RenderUrlAsPdf("https://ironpdf.com/")
Pdf.SaveAs("url.pdf")
VB   C#
  • 将 ASPX 页面转换为 PDF 等。
private void Form1_Load(object sender, EventArgs e)
{
IronPdf.AspxToPdf.RenderThisPageAsPdf();
//Changes the ASPX output into a pdf instead of HTML
}
private void Form1_Load(object sender, EventArgs e)
{
IronPdf.AspxToPdf.RenderThisPageAsPdf();
//Changes the ASPX output into a pdf instead of HTML
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
VB   C#

7.2.使用 DocRaptor 从 HTML 制作 PDF

DocRaptor 使用支持 JSON 的 HTTP post 请求处理转换,但只提供将 URL 和 HTML 文件转换为 PDF 的功能。

using DocRaptor.Client;
using DocRaptor.Model;
using DocRaptor.Api;
using System.IO;
 class Example {
   tatic void Main(string [] args) {
    DocApi docraptor = new DocApi();
    docraptor.Configuration.Username = "YOUR_API_KEY_HERE";
     Doc doc = new Doc(
      test: true,
      //documentContent: System.IO.File.ReadAllText(@"custom-fonts-    content.html"),
        documentUrl: "http://www.docraptor.com/examples/invoice.html",
        name: "docraptor-csharp.pdf",
        documentType: Doc.DocumentTypeEnum.Pdf
      );
          yte [] createResponse = docraptor.CreateDoc(doc);
    }
using DocRaptor.Client;
using DocRaptor.Model;
using DocRaptor.Api;
using System.IO;
 class Example {
   tatic void Main(string [] args) {
    DocApi docraptor = new DocApi();
    docraptor.Configuration.Username = "YOUR_API_KEY_HERE";
     Doc doc = new Doc(
      test: true,
      //documentContent: System.IO.File.ReadAllText(@"custom-fonts-    content.html"),
        documentUrl: "http://www.docraptor.com/examples/invoice.html",
        name: "docraptor-csharp.pdf",
        documentType: Doc.DocumentTypeEnum.Pdf
      );
          yte [] createResponse = docraptor.CreateDoc(doc);
    }
Imports DocRaptor.Client
Imports DocRaptor.Model
Imports DocRaptor.Api
Imports System.IO
 Friend Class Example
   Private tatic Sub Main(ByVal args() As String)
	Dim docraptor As New DocApi()
	docraptor.Configuration.Username = "YOUR_API_KEY_HERE"
	 Dim doc As New Doc(test:= True, documentUrl:= "http://www.docraptor.com/examples/invoice.html", name:= "docraptor-csharp.pdf", documentType:= Doc.DocumentTypeEnum.Pdf)
		  Dim createResponse() As yte = docraptor.CreateDoc(doc)
   End Sub
VB   C#

8.格式化 PDF

IronPDF 和 DocRaptor 都支持 PDF 格式化。 不过,IronPDF 提供单文件支持,而 DocRaptor 使用多文件支持。

8.1.使用 IronPDF 进行格式化

为了确保输出 PDF 的预期行为,我们在文章中使用了不同的格式样式,我们将讨论其中一些样式,并与 DocRaptor 进行比较。

  • 自定义字体

    IronPDF 支持网络字体,包括令人难以置信的 Google 字体库。 这样,开发人员就可以完全控制字体,而无需依赖系统字体。

using IronPdf;
ChromePdfRenderer myChromePdfRenderer = new IronPdf.ChromePdfRenderer();
var Renderer = new IronPdf.ChromePdfRenderer();
var html = @"<link href=""https://fonts.googleapis.com/css?family=Lobster""
rel=""stylesheet""><p style=""font-family: 'Lobster', serif; font-size:30px;"" > Hello Google Fonts</p>";
Renderer.RenderingOptions.RenderDelay = 500;
var doc = Renderer.RenderHtmlAsPdf(html);
doc.SaveAs("font.pdf");
using IronPdf;
ChromePdfRenderer myChromePdfRenderer = new IronPdf.ChromePdfRenderer();
var Renderer = new IronPdf.ChromePdfRenderer();
var html = @"<link href=""https://fonts.googleapis.com/css?family=Lobster""
rel=""stylesheet""><p style=""font-family: 'Lobster', serif; font-size:30px;"" > Hello Google Fonts</p>";
Renderer.RenderingOptions.RenderDelay = 500;
var doc = Renderer.RenderHtmlAsPdf(html);
doc.SaveAs("font.pdf");
IRON VB CONVERTER ERROR developers@ironsoftware.com
VB   C#
  • 水印

    IronPDF 提供用 HTML 给 PDF 文档 "加水印 "的方法。 水印可设置在现有内容的上方或下方,并具有不透明度、旋转和超链接等内置功能。

using IronPdf;
// Stamps a watermark onto a new or existing PDF
IronPdf.ChromePdfRenderer Renderer = new IronPdf.ChromePdfRenderer();
var Pdf = Renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf");
Pdf.WatermarkAllPages("<h2 style='color:red'>SAMPLE</h2>",   ronPdf.Editing.WaterMarkLocation.MiddleCenter, 50, -45, "https://www.nuget.org/packages/IronPdf");
Pdf.SaveAs(@"C:\Path\To\Watermarked.pdf
using IronPdf;
// Stamps a watermark onto a new or existing PDF
IronPdf.ChromePdfRenderer Renderer = new IronPdf.ChromePdfRenderer();
var Pdf = Renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf");
Pdf.WatermarkAllPages("<h2 style='color:red'>SAMPLE</h2>",   ronPdf.Editing.WaterMarkLocation.MiddleCenter, 50, -45, "https://www.nuget.org/packages/IronPdf");
Pdf.SaveAs(@"C:\Path\To\Watermarked.pdf
IRON VB CONVERTER ERROR developers@ironsoftware.com
VB   C#
  • 页码

    通过 IronPDF 的 "页眉和页脚 "功能,我们可以合并有关页码的信息。

// PM> Install-Package IronPdf
using IronPdf;
var html = @"
<p> Hello Iron</p>
<p> This is 1st Page </p>
<div style = 'page-break-after: always;' ></div>
<p> This is 2nd Page</p>
<div style = 'page-break-after: always;' ></div>
<p> This is 3rd Page</p>";
var Renderer = new IronPdf.ChromePdfRenderer();
Renderer.RenderingOptions.HtmlFooter = new IronPdf.HtmlHeaderFooter()
{
    MaxHeight = 15, //millimeters
    HtmlFragment = "<center><i>{page} of {total-pages}<i></center>",
    DrawDividerLine = true
};
var pdfdoc = Renderer.RenderHtmlAsPdf(html);
pdfdoc.SaveAs("pageNumber.pdf");
// PM> Install-Package IronPdf
using IronPdf;
var html = @"
<p> Hello Iron</p>
<p> This is 1st Page </p>
<div style = 'page-break-after: always;' ></div>
<p> This is 2nd Page</p>
<div style = 'page-break-after: always;' ></div>
<p> This is 3rd Page</p>";
var Renderer = new IronPdf.ChromePdfRenderer();
Renderer.RenderingOptions.HtmlFooter = new IronPdf.HtmlHeaderFooter()
{
    MaxHeight = 15, //millimeters
    HtmlFragment = "<center><i>{page} of {total-pages}<i></center>",
    DrawDividerLine = true
};
var pdfdoc = Renderer.RenderHtmlAsPdf(html);
pdfdoc.SaveAs("pageNumber.pdf");
' PM> Install-Package IronPdf
Imports IronPdf
Private html = "
<p> Hello Iron</p>
<p> This is 1st Page </p>
<div style = 'page-break-after: always;' ></div>
<p> This is 2nd Page</p>
<div style = 'page-break-after: always;' ></div>
<p> This is 3rd Page</p>"
Private Renderer = New IronPdf.ChromePdfRenderer()
Renderer.RenderingOptions.HtmlFooter = New IronPdf.HtmlHeaderFooter() With {
	.MaxHeight = 15,
	.HtmlFragment = "<center><i>{page} of {total-pages}<i></center>",
	.DrawDividerLine = True
}
Dim pdfdoc = Renderer.RenderHtmlAsPdf(html)
pdfdoc.SaveAs("pageNumber.pdf")
VB   C#

8.2.使用 DocRaptor 设置格式

DocRaptor 支持 .NET API 中的 PDF 格式化 - 但处理起来相当困难。 让我们看看之前的三个格式化示例:

  • 自定义字体

    在 DocRaptor 中使用自定义字体非常简单。 其工作方式与标准网页相同。 下面是一个使用 Google 字体的 CSS 示例:

    CSS 编码:

@font-face {
  font-family: 'Open Sans';
  font-style: normal;
  font-weight: 300;
  src: local('Open Sans Light'), local('OpenSans-Light'), url(http://themes.googleusercontent.com/static/fonts/opensans/v8/DXI1ORHCpsQm3Vp6mXoaTaRDOzjiPcYnFooOUGCOsRk.woff) format('woff');
}
p {
  font-family: Arial, Helvetica, sans-serif;
}
p.custom-font {
  font-family: 'Open Sans', sans-serif;
}
@font-face {
  font-family: 'Open Sans';
  font-style: normal;
  font-weight: 300;
  src: local('Open Sans Light'), local('OpenSans-Light'), url(http://themes.googleusercontent.com/static/fonts/opensans/v8/DXI1ORHCpsQm3Vp6mXoaTaRDOzjiPcYnFooOUGCOsRk.woff) format('woff');
}
p {
  font-family: Arial, Helvetica, sans-serif;
}
p.custom-font {
  font-family: 'Open Sans', sans-serif;
}
HTML

HTML 编码:

<h2>Custom Fonts</h2>
<p>Hi, my name is Arial.</p>
<p class='custom-font'>I like to walk on the beach on warm Open Sans.</p>
<h2>Custom Fonts</h2>
<p>Hi, my name is Arial.</p>
<p class='custom-font'>I like to walk on the beach on warm Open Sans.</p>
HTML

C# 编码:

class Example
{
    static void Main(string [] args)
    {
        DocApi docraptor = new DocApi();
        docraptor.Configuration.Username = "YOUR_API_KEY_HERE";
         try
        {
            Doc doc = new Doc(
                name: "custom-fonts",
                test: true, // test documents are free but watermarked
                documentContent: System.IO.File.ReadAllText(@"custom-fonts-content.html"), 
                 / documentUrl: "http://docraptor.com/examples/invoice.html", // or use a url
                documentType: Doc.DocumentTypeEnum.Pdf
                // javascript: false, // enables   rocessing
            );
             byte [] create_response = docraptor.CreateDoc(doc);
            File.WriteAllBytes("custom-fonts.pdf", create_response);
        } catch (DocRaptor.Client.ApiException error) {
            Console.Write(error.ErrorContent);
        }
    }
}
class Example
{
    static void Main(string [] args)
    {
        DocApi docraptor = new DocApi();
        docraptor.Configuration.Username = "YOUR_API_KEY_HERE";
         try
        {
            Doc doc = new Doc(
                name: "custom-fonts",
                test: true, // test documents are free but watermarked
                documentContent: System.IO.File.ReadAllText(@"custom-fonts-content.html"), 
                 / documentUrl: "http://docraptor.com/examples/invoice.html", // or use a url
                documentType: Doc.DocumentTypeEnum.Pdf
                // javascript: false, // enables   rocessing
            );
             byte [] create_response = docraptor.CreateDoc(doc);
            File.WriteAllBytes("custom-fonts.pdf", create_response);
        } catch (DocRaptor.Client.ApiException error) {
            Console.Write(error.ErrorContent);
        }
    }
}
Friend Class Example
	Shared Sub Main(ByVal args() As String)
		Dim docraptor As New DocApi()
		docraptor.Configuration.Username = "YOUR_API_KEY_HERE"
		 Try
			Dim doc As New Doc(name:= "custom-fonts", test:= True, documentContent:= System.IO.File.ReadAllText("custom-fonts-content.html"), / documentUrl:= "http://docraptor.com/examples/invoice.html", documentType:= Doc.DocumentTypeEnum.Pdf)
			 Dim create_response() As Byte = docraptor.CreateDoc(doc)
			File.WriteAllBytes("custom-fonts.pdf", create_response)
		Catch [error] As DocRaptor.Client.ApiException
			Console.Write([error].ErrorContent)
		End Try
	End Sub
End Class
VB   C#

输出

  • 水印

    很多 PDF 文件上都可能有水印。 幸运的是,DocRaptor 的 HTML-PDF 工具有助于轻松创建动态生成的水印文档!

    CSS 编码:

#watermark {
  flow: static(watermarkflow);
  font-size: 120px;
  opacity: 0.5;
  transform: rotate(-30deg);
  text-align: center;
}
#watermark {
  flow: static(watermarkflow);
  font-size: 120px;
  opacity: 0.5;
  transform: rotate(-30deg);
  text-align: center;
}
HTML

HTML 编码:

<body><div id="watermark">PREVIEW</div>
<div style="page-break-after: always;">Page 1</div>
<div style="page-break-after: always;">Page 2</div>
<div style="page-break-after: always;">Page 3</div>
</body>
<body><div id="watermark">PREVIEW</div>
<div style="page-break-after: always;">Page 1</div>
<div style="page-break-after: always;">Page 2</div>
<div style="page-break-after: always;">Page 3</div>
</body>
HTML

C# 编码:

class Example
{
    static void Main(string [] args)
    {
        DocApi docraptor = new DocApi();
        docraptor.Configuration.Username = "YOUR_API_KEY_HERE";
        try
        {
            Doc doc = new Doc(
                name: "text-based-watermark",
                test: false, // test documents are free but watermarked
                documentContent: System.IO.File.ReadAllText(@"text-based-watermark-content.html"), 
                // documentUrl: "http://docraptor.com/examples/invoice.html", // or use a url
                documentType: Doc.DocumentTypeEnum.Pdf
                // javascript: false, // enables processing
            );
            byte [] create_response = docraptor.CreateDoc(doc);
            File.WriteAllBytes("text-based-watermark.pdf", create_response);
        } catch (DocRaptor.Client.ApiException error) {
            Console.Write(error.ErrorContent);
        }
    }
class Example
{
    static void Main(string [] args)
    {
        DocApi docraptor = new DocApi();
        docraptor.Configuration.Username = "YOUR_API_KEY_HERE";
        try
        {
            Doc doc = new Doc(
                name: "text-based-watermark",
                test: false, // test documents are free but watermarked
                documentContent: System.IO.File.ReadAllText(@"text-based-watermark-content.html"), 
                // documentUrl: "http://docraptor.com/examples/invoice.html", // or use a url
                documentType: Doc.DocumentTypeEnum.Pdf
                // javascript: false, // enables processing
            );
            byte [] create_response = docraptor.CreateDoc(doc);
            File.WriteAllBytes("text-based-watermark.pdf", create_response);
        } catch (DocRaptor.Client.ApiException error) {
            Console.Write(error.ErrorContent);
        }
    }
Friend Class Example
	Shared Sub Main(ByVal args() As String)
		Dim docraptor As New DocApi()
		docraptor.Configuration.Username = "YOUR_API_KEY_HERE"
		Try
			Dim doc As New Doc(name:= "text-based-watermark", test:= False, documentContent:= System.IO.File.ReadAllText("text-based-watermark-content.html"), documentType:= Doc.DocumentTypeEnum.Pdf)
			Dim create_response() As Byte = docraptor.CreateDoc(doc)
			File.WriteAllBytes("text-based-watermark.pdf", create_response)
		Catch [error] As DocRaptor.Client.ApiException
			Console.Write([error].ErrorContent)
		End Try
	End Sub
VB   C#
  • 页码

    使用开源 HTML 转 PDF 工具,在 PDF 文档中添加页码非常困难,有时甚至几乎不可能,但 DocRaptor 让这一切变得轻而易举!

    CSS 编码:

@page {
  @bottom {
    content: "Page " counter(page, upper-alpha) " of " counter(pages, decimal);
  } } 
@page {
  @bottom {
    content: "Page " counter(page, upper-alpha) " of " counter(pages, decimal);
  } } 
HTML

HTML 编码:

<body>
<div style="page-break-after: always;">Page1</div>
<div style="page-break-after: always;">Page2</div>
<div style="page-break-after: always;">Page3</div>
<div id="page4" style="page-break-after: always;">Page4, with reset page counter</div>
</body>
<body>
<div style="page-break-after: always;">Page1</div>
<div style="page-break-after: always;">Page2</div>
<div style="page-break-after: always;">Page3</div>
<div id="page4" style="page-break-after: always;">Page4, with reset page counter</div>
</body>
HTML

C# 编码:

class Example
{
    static void Main(string [] args)
    {
        DocApi docraptor = new DocApi();
        docraptor.Configuration.Username = "YOUR_API_KEY_HERE";
        try
        {
            Doc doc = new Doc(
                name: "page-numbers",
                test: true, // test documents are  but watermarked
                documentContent: System.IO.File.ReadAllText(@"page-numbers-content.html"), 
                // documentUrl: "http://docraptor.com/examples/invoice.html", // or use a url
                documentType: Doc.DocumentTypeEnum.Pdf
                // javascript: false, // enables processing
            );
            byte [] create_response = docraptor.CreateDoc(doc);
            File.WriteAllBytes("page-numbers.pdf", create_response);
        } catch (DocRaptor.Client.ApiException error) {
            Console.Write(error.ErrorContent);
        }
    }
}
class Example
{
    static void Main(string [] args)
    {
        DocApi docraptor = new DocApi();
        docraptor.Configuration.Username = "YOUR_API_KEY_HERE";
        try
        {
            Doc doc = new Doc(
                name: "page-numbers",
                test: true, // test documents are  but watermarked
                documentContent: System.IO.File.ReadAllText(@"page-numbers-content.html"), 
                // documentUrl: "http://docraptor.com/examples/invoice.html", // or use a url
                documentType: Doc.DocumentTypeEnum.Pdf
                // javascript: false, // enables processing
            );
            byte [] create_response = docraptor.CreateDoc(doc);
            File.WriteAllBytes("page-numbers.pdf", create_response);
        } catch (DocRaptor.Client.ApiException error) {
            Console.Write(error.ErrorContent);
        }
    }
}
Friend Class Example
	Shared Sub Main(ByVal args() As String)
		Dim docraptor As New DocApi()
		docraptor.Configuration.Username = "YOUR_API_KEY_HERE"
		Try
			Dim doc As New Doc(name:= "page-numbers", test:= True, documentContent:= System.IO.File.ReadAllText("page-numbers-content.html"), documentType:= Doc.DocumentTypeEnum.Pdf)
			Dim create_response() As Byte = docraptor.CreateDoc(doc)
			File.WriteAllBytes("page-numbers.pdf", create_response)
		Catch [error] As DocRaptor.Client.ApiException
			Console.Write([error].ErrorContent)
		End Try
	End Sub
End Class
VB   C#

9.许可

DocRaptor 是一款基于 API 的文档转换器,可将 HTML 文件和 URL 转换为 PDF,以及将 XML 转换为 XLSX 文件。 它支持八种不同的编程语言。 不过,它只提供有文档限制的月度许可,从每月 5 份文档限制的免费许可,到包括 40,000 份文档限制的白银套餐,每月标价为 1000 美元。 DocRaptor 非常适合小型机构使用,它提供一个较小的专业软件包,文件数量限制为 325 份,售价 29 美元。 链接 了解更多价格。

注:

DocRaptor 不提供一次性购买或基于项目的许可证。

IronPDF 是一个免费提供开发者许可证的库。 IronPDF 还具有独特的定价结构:简装版起价为 $749,没有任何隐藏费用。 SaaS 和 OEM 产品也可以重新分配。 所有许可证均附带 30 天退款保证、一年的软件支持和升级、开发/暂存/生产有效性以及永久许可证。 (一次性购买). 要查看 IronPDF 的整个价格结构和许可证,请转到 这里.

注:

IronPDF 提供将两个或多个 PDF 文件连接在一起的选项。 它还提供提取页面、复制页面、删除特定页面和多线程生成 PDF 的选项,这是竞争对手所不具备的。

10.摘要

从远程服务器,IronPDF 不会将 HTML 生成 PDF。 在幕后,它会启动一个真正符合标准的浏览器实例 (无需安装任何其他软件). HTML 的渲染是完全准确的,而且是矢量格式,适合按照最高标准进行商业印刷。 结果就是一份清晰、高质量的 PDF 文件。 许可证和价格信息可在网页上随时查阅。

DocRaptor 还能将任何格式的 HTML 转换为 PDF,而且准确性最高,停机时间最短,这要归功于它在众多云服务器上运行。 DocRaptor 是一个基于网络的 API,提供在线 PDF 转换服务。DocRaptor HTML to PDF API 使用简单,这要归功于服务器端 API 客户端库。 这些库可以在许多著名的服务器端编程语言中找到。 网页上有价格信息。

11.结论

在上述文章中,我们比较了这两款工具,并得出结论:对于 .NET 或 C# 文档转换,开发人员更喜欢 IronPDF 而不是 DocRaptor,原因有很多。 IronPDF 提供比 DocRaptor 更多的功能。 DocRaptor 为小型机构提供了很好的软件包,但价格昂贵,而且不提供长期持续许可。 另一方面,IronPDF 提供了更多的功能和一次性购买许可证,而且价格更低。无论是小型企业还是大型基础设施企业,IronPDF 都是首选。 DocRaptor 在处理不同服务器端平台上的 PDF 文件时非常有用。 此外,IronPDF 软件包提供终身许可,没有持续成本,而 DocRaptor 则有持续成本。

< 前一页
IronPDF与PDFCrowd的比较
下一步 >
IronPDF和DynamicPDF - 全面比较

准备开始了吗? 版本: 2024.9 刚刚发布

免费NuGet下载 总下载量: 10,731,156 查看许可证 >