如何在arm32上将html转换为pdf,而无需安装wkhtmltopdf



我正在尝试在arm32(NXP i.MX6 ARM Cortex A9(上将html文档转换为pdf。我正在用 C# 编写应用程序作为 .网芯应用程序。我遇到的问题是,我尝试过的所有事情都没有奏效,我还没有找到解决方案。

我尝试使用几个外部库来做到这一点,根据他们的支持团队,其中大多数仅适用于Windows,因此它们不起作用的原因很明显(例如EvoPdf,SelectPdf,HiQPdf等(。我尝试过的那些我认为应该适用于linux的是Ironpdf,wkHtmlToPdf(OpenHtmlToPdf,SharkPdf等(的包装器,pdfTron和无头铬。它们都给出了不同的错误:

Ironpdf抱怨没有安装库(我已经通过电子邮件发送给他们的支持,以便他们可能会解决这个问题(。IronPdf.Installation.LinuxAndDockerDependenciesAutoConfig = true在我的代码中设置,但我仍然收到错误,告诉我将其设置为true。

One or more errors occurred. (The Docker or Linux image is missing dependencies for IronPDF.
Please read https://ironpdf.com/docs/questions/docker-linux/
You may alternatively set IronPdf.Installation.LinuxAndDockerDependenciesAutoConfig = true to automatically resolve this issue.)

OpenHtmlToPdf包含wkHtmlToPdf,但它给出了权限被拒绝错误。

at Interop.Sys.ForkAndExecProcess(String filename, String[] argv, String[] envp, String cwd, Boolean redirectStdin, Boolean redirectStdout, Boolean redirectStderr, Boolean setUser, UInt32 userId, UInt32 groupId, Int32& lpChildPid, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean shouldThrow)
at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
at OpenHtmlToPdf.HtmlToPdfConverterProcess.Convert(ConversionSource conversionSource)
at OpenHtmlToPdf.Pdf.DocumentBuilder.ReadContentUsingTemporaryFile(String temporaryFilename)
at OpenHtmlToPdf.Pdf.DocumentBuilder.Content()
at OpenHTML2pdf.Program.Main(String[] args) in 

wkHtmlToPdf包装器与wkHtmlToPdf外部说它找不到wkHtmlToPdf(我无法安装它,所以这个很明显为什么它不起作用(

pdfTron表示它无法加载它使用的库之一。

Unhandled Exception: System.DllNotFoundException: Unable to load shared library 'PDFNetC' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libPDFNetC: cannot open shared object file: No such file or directory
at pdftron.PDFNetPINVOKE.TRN_PDFDocCreate(IntPtr& doc)
at pdftron.PDF.PDFDoc..ctor()

无头铬会给出导航错误,但它应该找到正确的文件。

$ chromium-browser --headless --disable-gpu --print-to-pdf=file1.pdf --no-margins file1.html  
[0930/085730.493897:WARNING:audio_manager.cc(295)] Multiple instances of AudioManager detected 
[0930/085730.494843:WARNING:audio_manager.cc(254)] Multiple instances of AudioManager detected 
[0930/085730.514971:ERROR:headless_shell.cc(100)] Navigation to  failed

有没有人有解决这些错误的方法或关于可能有用的东西的提示?我觉得我不能靠自己走得更远。

Macports 为 Mac M1 机器提供了一个 wkhtmltopdf arm64 端口。也许您可以将他们的构建脚本调整为 arm32。https://ports.macports.org/port/wkhtmltopdf/details/

对于我的标签打印用途,wkhtmltopdf 不能生成非常准确的结果。 我已经为libHaru(http://libharu.org/(创建了一个c#包装器来直接生成pdf。

最近我发现了 nuget 包 Haru.Net,https://www.nuget.org/packages/Haru.Net 自述文件中的:"Libharu (Haru FREE PDF Library( net451+ 和 netstandard2.0(包括 netcore(的 .NET 包装器。该软件包由win32,win64,linux64(在CentOS 7上测试(,linux arm32,linux arm64和MacOS的预编译二进制文件组成。

最新更新