首页 > 解决方案 > 如何在不安装 wkhtmltopdf 的情况下在 arm32 上将 html 转换为 pdf

问题描述

我正在尝试在 arm32(NXP i.MX6 ARM Cortex A9)上将 html 文档转换为 pdf。我正在用 C# 编写应用程序作为 .NetCore 应用程序。我遇到的问题是,我尝试过的所有方法都不起作用,而且我还没有找到解决方法。

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

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,但它给出了 Permission Denied 错误。

   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()

Headless chrome会出现导航错误,但它应该会找到正确的文件。

$ 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

有没有人有任何这些错误的解决方案或关于可能有用的东西的提示?我觉得我一个人也走不下去了。

标签: c#armpdf-generationwkhtmltopdfgoogle-chrome-headless

解决方案


推荐阅读