c# - 如何在不安装 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
有没有人有任何这些错误的解决方案或关于可能有用的东西的提示?我觉得我一个人也走不下去了。
解决方案
推荐阅读
- python - 在 m2m_changed 信号中迭代对象
- react-native - 使用 react-native 导航时在顶部获得空白
- android - 我们在 React Native App for Android 中设置 http://localhost:8081/
- asp.net-mvc - Linux 上的 ASP.NET Core 与 itextsharp 的问题
- python - 使用 Tensorflow 构建 RNN。如何正确预处理我的数据集以匹配 RNN 的输入和输出形状?
- flask - 无法在本地网络中访问 Flask 应用程序
- django - Celery - 如何获取 shared_task 的任务 ID?
- macos - ubuntu 18.04.1 in paralles desktop on mac arrowkey down and up 异常
- python - Pandas 数据框 OrderedDict 提取数据
- amazon-web-services - Azure Databricks 是否安全地挂载 S3