在Web服务器上将HTML转换为PDF, DOC, TXT, TIFF, JPEG。无GUI。
Windows
2000/2003/Vista
7/8/10/11
and
2012/2016/2019/2022 Server
and
Docker/Citrix/Wine
Total HTML Converter X 是一款服务器端 SDK,可将 HTML 文件和实时 URL 转换为 PDF、DOC、RTF、XLS、TIFF、JPG、PNG 和 TXT — 完整的 CSS 渲染,无需在服务器上安装无头 Chrome,也无需依赖打印服务。它以静默方式运行:无 GUI、无对话框、无弹窗。Total HTML Converter X 同时提供命令行二进制文件和 ActiveX/COM 接口,因此可直接嵌入 ASP、PHP、.NET、Python、Ruby、Java 以及任何支持 COM 的后端。
两种源模式:本地 HTML/MHT 文件路径,或由转换器直接抓取的远程 URL(适用于"将实时页面渲染为 PDF"的场景)。输出格式覆盖:
Total HTML Converter X 识别所有 HTML 标签,包括通过 CSS 1/2 样式控制分页符,支持 IE 风格的页眉页脚(日期、时间、页数、自定义水印),自动将 HTML 宽度适配到所选 PDF 页面尺寸(在打印宽幅 HTML 表格时尤为关键),可提取元数据用于数据库索引,并支持以文件夹掩码或队列文件批量处理静态文件和实时 URL。
多用户友好:同一台 Windows 服务器既可在 LAN 上运行客户端-服务器部署,也可将转换功能作为 Web 服务对外提供。多线程引擎以最高速度处理批量任务。兼容 IIS、Docker、Citrix 和 Wine。
免费试用(30 天试用期,无功能限制),亲自体验它的真正价值。
当前支持的部分文件格式转换:
|
|
|
string src = @"C:\test\Source.html";
string dest = @"C:\test\Dest.pdf";
var cnv = new HTMLConverterX();
cnv.Convert(src, dest, "-cPDF -log c:\\test\\HTML.log");
if (!string.IsNullOrEmpty(cnv.ErrorMessage))
throw new Exception(cnv.ErrorMessage);
public static class Function1
{
[FunctionName("Function1")]
public static async Task Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
ILogger log)
{
StringBuilder sbLogs = new StringBuilder();
sbLogs.AppendLine("started...");
try
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = true;
startInfo.UseShellExecute = false;
var assemblyDirectoryPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
assemblyDirectoryPath = assemblyDirectoryPath.Substring(0, assemblyDirectoryPath.Length - 4);
var executablePath = $@"{assemblyDirectoryPath}\Converter\HTMLConverterX.exe";
sbLogs.AppendLine(executablePath + "...");
var srcPath = $@"{assemblyDirectoryPath}\src\sample.html";
var outPath = Path.GetTempFileName() + ".pdf";
startInfo.FileName = executablePath;
if (File.Exists(outPath))
{
File.Delete(outPath);
}
if (File.Exists(executablePath) && File.Exists(srcPath))
{
sbLogs.AppendLine("files exists...");
}
else
sbLogs.AppendLine("EXE & source files NOT exists...");
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.Arguments = $"\"{srcPath}\" \"{outPath}\" -cPDF";
using (Process exeProcess = Process.Start(startInfo))
{
sbLogs.AppendLine($"wait...{DateTime.Now.ToString()}");
exeProcess.WaitForExit();
sbLogs.AppendLine($"complete...{DateTime.Now.ToString()}");
}
sbLogs.AppendLine("Conversion complete.");
}
catch (Exception ex)
{
sbLogs.AppendLine(ex.ToString());
}
return new OkObjectResult(sbLogs);
}
}
dim C
Set C=CreateObject("HTMLConverter.HTMLConverterX")
C.Convert "c:\source.html", "c:\dest.jpg", "-cJPG -log c:\html.log"
C.Convert "https://www.coolutils.com/", "c:\URL Page.pdf", "-cPDF -log c:\html.log"
Response.Write C.ErrorMessage
set C = nothing
dim C
Set C=CreateObject("HTMLConverter.HTMLConverterX")
Response.Clear
Response.AddHeader "Content-Type", "binary/octet-stream"
Response.AddHeader "Content-Disposition", "attachment; filename=test.pdf"
Response.BinaryWrite C.ConvertToStream("C:\www\ASP\Source.html", "C:\www\ASP", "-cpdf -log c:\html.log")
set C = nothing
$src="C:\\test\\test.html";
$dest="C:\\test\\test.pdf";
if (file_exists($dest)) unlink($dest);
$c= new COM("HTMLConverter.HTMLConverterX");
$c->convert($src,$dest, "-cPDF -log c:\\HTML.log");
if (file_exists($dest)) echo "OK"; else echo "fail:".$c->ErrorMessage;
require 'win32ole'
c = WIN32OLE.new('HTMLConverter.HTMLConverterX')
src = "C:\\test\\test.html"
dest = "C:\\test\\test.pdf"
c.convert(src, dest, "-cPDF -log c:\\test\\HTML.log")
if not File.exist?(dest)
puts c.ErrorMessage
end
import win32com.client
import os.path
c = win32com.client.Dispatch("HTMLConverter.HTMLConverterX")
src = "C:\\test\\test.html"
dest = "C:\\test\\test.pdf"
c.convert(src, dest, "-cPDF -log c:\\test\\HTML.log")
if not os.path.exists(dest):
print(c.ErrorMessage)
uses Dialogs, Vcl.OleAuto;
var
c: OleVariant;
begin
c := CreateOleObject('HTMLConverter.HTMLConverterX');
c.Convert('c:\test\source.html', 'c:\test\dest.pdf', '-cPDF -log c:\test\HTML.log');
if c.ErrorMessage <> '' then
ShowMessage(c.ErrorMessage);
end;
var c = new ActiveXObject("HTMLConverter.HTMLConverterX");
c.Convert("C:\\test\\source.html", "C:\\test\\dest.pdf", "-cPDF");
if (c.ErrorMessage != "")
alert(c.ErrorMessage)
use Win32::OLE; my $src = "C:\\test\\test.html"; my $dest = "C:\\test\\test.pdf"; my $c = CreateObject Win32::OLE 'HTMLConverter.HTMLConverterX'; $c->convert($src, $dest, "-cPDF -log c:\\test\\HTML.log"); print $c->ErrorMessage if -e $dest;
"我选择 Total HTML Converter X 有几个原因。首先,你们能够提供我们所需的一些功能,而其他转换器表示无法做到(包括在每页保持相同页眉以及不在跨页时拆分表格行的能力)。其次,在我们购买产品之前,你们就非常支持并迅速响应我们的请求。第三,当我们说明情况后,你们愿意调整第二个免版税许可证的价格。第四,你们看起来非常以客户为中心,我感觉你们在我们购买产品后不会忽视我们 — 事实证明我是对的!"
Andy Poulsen
www.asp-inno.com
"我们在自己的模板引擎中将每日投资组合报告渲染为 HTML,然后通过 Total HTML Converter X 处理 HTML,生成带有数字签名、可交付给客户的 PDF。-PFXFile/-PFXPass 签名场景只需调用一次二进制文件,无需单独的后处理。每晚约 4,000 份报告,多次运行结果一致。我们替换了一个 wkhtmltopdf 流水线,原来在异步加载字体时会崩溃;内置渲染器开箱即用。"
Stefan H.
Senior Backend Developer at a financial-reporting platform
"客户从我们的 CMS 导出文章,希望以 PDF 形式存档。Total HTML Converter X 配合 -HeadText/-FootText 在每一页应用发布元数据,自动适配 HTML 宽度的功能让编辑表格无需为每个模板编写自定义 CSS。在 Windows Server Core 上无界面运行,没有 Chromium,也没有意外。已在生产环境运行五年,对于典型文章 HTML,我们硬件上的吞吐量约为每秒 80 页。"
Margit V.
DevOps Engineer at a CMS platform
"我们在内联网发布产品中以免版税许可证的方式捆绑了 Total HTML Converter X。一次性按项目收费仅为基于 wkhtmltopdf 的商业封装产品所要求的重新分发授权费的一小部分。我们的安装程序部署并注册了 ActiveX,应用直接调用它,最终用户只看到我们自己的 UI。32 位 ActiveX 限制使我们花了几天时间重做流水线,但当我们询问解决方法时,技术支持响应迅速。"
Carlos P.
Independent Software Vendor
"面向客户的仪表盘是 HTML;部分用户希望保留 PDF 快照作为存档。我们提供了一个'下载为 PDF'的链接,调用 Total HTML Converter X 处理已渲染仪表盘的实时 URL。转换器通过基于 cookie 的会话登录,并生成完全相同的 PDF 渲染。CSS 分页符控制被精确遵循,因此多节仪表盘可以干净利落地分页。CLI 稳定、文档完善,-log -verbosity detail 让调试变得轻松。"
Akari N.
Lead .NET Developer at a partner-portal SaaS
Developers and IT teams that convert HTML to PDF, DOC, and images on web servers via ActiveX
Add HTML conversion to your web application via ActiveX
Web developers integrate Total HTML ConverterX into ASP, PHP, or .NET applications to convert user-submitted HTML files to PDF, DOC, or images on the server. Multiple users perform simultaneous conversions with no GUI interruptions — the converter runs silently and returns results automatically.
Convert HTML reports to PDF with digital signatures
Enterprise applications generate HTML reports on the server and use Total HTML ConverterX to convert them to PDF for delivery. Add digital signatures for document authenticity, apply custom watermarks, and auto-fit wide HTML tables to the chosen page size — all as part of the automated report pipeline.
Convert HTML content to standard formats for archival
Document management systems use Total HTML ConverterX to convert incoming HTML files, saved web pages, and email templates to PDF or TIFF for standardized storage. The converter recognizes all HTML tags and CSS styles, producing faithful output with headers, footers, and metadata extraction for database indexing.
Serve HTML conversion to all users on your local network
Organizations deploy Total HTML ConverterX as a client-server application on the local network. Employees across departments submit HTML files for conversion to PDF, XLS, or TIFF through a shared service — eliminating the need to install desktop converters on every workstation.
Batch-convert HTML files via command line on servers
IT teams run Total HTML ConverterX via command line in scheduled batch jobs and automated workflows. HTML output from web scrapers, CMS exports, or application logs is converted to PDF or images on arrival. Errors are saved to a log file for monitoring — no pop-ups or user interaction required.
Total HTML ConverterX 附带 HTMLConverterX.exe,这是一个可以从 .bat 脚本、计划任务、PHP/.NET 后端或任何服务器端工作进程调用的控制台二进制程序。标志集镜像 GUI 版的 HtmlConverter.exe;完整参考请参阅命令行文档。下面的配方涵盖了我们最常从 SDK 客户那里听到的请求。
最简单的调用 —— 一个源文件、一个输出、一个目标格式。
HTMLConverterX.exe "C:\pages\index.html" "C:\out\index.pdf" -cPDF
处理文件夹中的每个 HTML 文件,并将 PDF 放入同级输出目录。
HTMLConverterX.exe "C:\pages\*.html" "C:\out\" -cPDF
将掩码替换为 *.mht、*.mhtml 或 *.htm 以选择不同的源格式。
源参数可以是 URL,而不仅仅是文件路径。Chrome 渲染引擎处理现代 CSS、Web 字体和 JavaScript 密集型页面。
HTMLConverterX.exe "https://www.coolutils.com" "C:\out\coolutils.pdf" -cPDF -engine chrome
文档站点和导出的 wiki 很少存在于一个平面文件夹中。-Recurse 遍历子目录;-kfs 在输出端重新创建相同的树,而不是将每个文件展平到一个桶中。
HTMLConverterX.exe "C:\docs\manual\*.html" "C:\out\manual\" -cPDF -Recurse -kfs
典型的导出整个网站作业:数十个属于一起的页面。-combine 按源文件顺序合并它们,-toc 生成目录。
HTMLConverterX.exe "C:\docs\manual\*.html" "C:\out\manual.pdf" -cPDF -combine -toc -sort name
当目标是多页 TIFF 时,请使用 -Multipage 而不是 -combine。
报告通常需要在每页顶部有标题,在底部有"第 1 页/共 10 页"。[page] 和 [date] 占位符在渲染时展开。
HTMLConverterX.exe "C:\pages\*.html" "C:\out\" -cPDF -HeadText "Acme Quarterly Report — [date]" -HeadAlign center -FootText "Page [page]" -FootAlign right
向客户发送草稿的标准做法:所有者密码锁定编辑/打印权限,用户密码控制文件打开,水印标记每页。
HTMLConverterX.exe "C:\pages\*.html" "C:\out\" -cPDF -mp "owner-pwd" -up "user-pwd" -perm Print -wmt "CONFIDENTIAL" -wmr 45 -wtr 30
用 Copy、Modify、Annotation、FormFill、HighResPrint 的任意组合替换 Print,以准确授予您想要的权限。
对于需要可验证签名者的合同、发票和其他文档。PFX 文件保存证书;-PFXPass 解锁它。
HTMLConverterX.exe "C:\pages\contract.html" "C:\out\contract.pdf" -cPDF -PFXFile "C:\certs\acme.pfx" -PFXPass "cert-pwd" -SignName "Acme Legal" -SignLoc "New York, NY" -SignRes "Approved by counsel"
用于需要符合 ISO 19005 PDF/A 文件且具有适当创作元数据的记录管理工作流。
HTMLConverterX.exe "C:\pages\*.html" "C:\archive\" -cPDF -pdfa -PDFAuthor "Acme Inc." -PDFTitle "Knowledge Base 2026" -PDFSubject "Support articles snapshot"
当工作进程写入队列文件而转换器消耗它时,您不希望在命令行上编码每个路径。-list 从文本文件中读取文件掩码(每行一个);-verbosity detail 每个文件写一行日志;-logmode append 在多次运行之间保留历史。
HTMLConverterX.exe -list "C:\queues\batch.txt" "C:\out\" -cPDF -log "C:\logs\htmlconv.log" -verbosity detail -logmode append
|
|
|
C.Convert("https://www.example.com/report", "c:\out\report.pdf", "-cPDF")。该功能广泛用于按计划将实时状态仪表盘、生成的报告或合作伙伴门户页面渲染为 PDF。new COM("HTMLConverter.HTMLConverterX"),.NET 中使用 new HTMLConverterX(),Python 中使用 win32com.client.Dispatch("HTMLConverter.HTMLConverterX"),Ruby 中使用 WIN32OLE.new('HTMLConverter.HTMLConverterX')。或者,HTMLConverterX.exe 命令行二进制文件可以从任何进程、调度程序或 shell 脚本调用。还提供通过 ConvertToStream 直接进行 PDF 流式传输,适用于 ASP/PHP Web 响应。-PFXFile "C:\certs\cert.pfx" -PFXPass "cert-pwd" 通过 X.509 证书对输出 PDF 进行数字签名。-HeadText 和 -FootText 添加自定义页眉/页脚,并支持模板令牌如 [page]、[date]、[time] — 等同于 IE 的打印页眉。还支持水印(文本或图像)、AES-256 加密以及按权限标志(-perm Print|Copy|Modify)。page-break-before、page-break-after、page-break-inside: avoid)控制的分页符也会被遵循,因此行或节等逻辑单元在跨页时保持完整。-PageSize 为每个任务设置目标纸张大小(A4、Letter、Legal 等)。