标签: dinktopdf

Mac M1 上的 DinkToPdf

我在 .NET 6.0 WebAPI 应用程序中实现 dinkToPdf NuGet 包时遇到问题。我使用的是配备 M1 芯片的 MacBook。

我收到以下错误:

"Unable to load shared library '/Users/vlatkopetrushevski/Desktop/Work/TechUp/Back End/academy-management-api/Skillup.API/wkhtmltox/v0.12.4/64 bit/libwkhtmltox.dylib' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(/Users/vlatkopetrushevski/Desktop/Work/TechUp/Back End/academy-management-api/Skillup.API/wkhtmltox/v0.12.4/64 bit/libwkhtmltox.dylib, 0x0001): tried: '/Users/vlatkopetrushevski/Desktop/Work/TechUp/Back End/academy-management-api/Skillup.API/wkhtmltox/v0.12.4/64 bit/libwkhtmltox.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))"
Run Code Online (Sandbox Code Playgroud)

有人有同样的问题吗?

.net c# arm64 dinktopdf apple-m1

8
推荐指数
1
解决办法
711
查看次数

在 azure 中作为应用服务发布后,在使用 DinkToPDF 进行 PDF 转换时无法加载外部库“libwkhtmltox.dll”

我正在使用 DinkToPDF 库将 html 字符串转换为等效的 PDF。要使用这个库,我们必须导入提供的本地库 libwkhtmltox.dll。当我在本地运行我的 .net 核心项目时,这工作正常,但是当我尝试在 Azure 中将我的 Web 项目发布为应用服务时,我收到以下错误,

未处理的异常:System.DllNotFoundException:无法加载共享库“/home/site/wwwroot/libwkhtmltox.dll”或其依赖项之一。为了帮助诊断加载问题,请考虑设置 LD_DEBUG 环境变量: /home/site/wwwroot/libwkhtmltox.dll: cannot open shared object file: No such file or directory

我在 startup.cs 文件中提到了库的用法,如下所示。

    internal class CustomAssemblyLoadContext : AssemblyLoadContext
    {
        public IntPtr LoadUnmanagedLibrary(string absolutePath)
        {
            return LoadUnmanagedDll(absolutePath);
        }
        protected override IntPtr LoadUnmanagedDll(String unmanagedDllName)
        {
            return LoadUnmanagedDllFromPath(unmanagedDllName);
        }

        protected override Assembly Load(AssemblyName assemblyName)
        {
            throw new NotImplementedException();
        }
    }
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddSingleton(typeof(IConverter), new SynchronizedConverter(new PdfTools()));
            var context = new CustomAssemblyLoadContext();
            context.LoadUnmanagedLibrary(Path.Combine(Directory.GetCurrentDirectory(), "libwkhtmltox.dll")); …
Run Code Online (Sandbox Code Playgroud)

azure .net-core dinktopdf

6
推荐指数
1
解决办法
2500
查看次数

DinkToPdf Net Core 无法加载 DLL 文件

我正在尝试使用DinkToPdf库从 HTML SQL 服务器数据库生成 PDF 。

在我添加的启动文件中:

var context = new CustomAssemblyLoadContext();
context.LoadUnmanagedLibrary(Path.Combine(Directory.GetCurrentDirectory(), "libwkhtmltox.dll"));
Run Code Online (Sandbox Code Playgroud)

该行在启动网络应用程序时给了我这个错误:

DllNotFoundException:无法加载 DLL 'C:\Program Files\IIS Express\libwkhtmltox.dll' 或其依赖项之一:找不到指定的模块。(来自 HRESULT 的异常:0x8007007E)

System.Runtime.Loader.AssemblyLoadContext.InternalLoadUnmanagedDllFromPath(string unmanagedDllPath)

DllNotFoundException:无法加载 DLL 'C:\Program Files\IIS Express\libwkhtmltox.dll' 或其依赖项之一:找不到指定的模块。(来自 HRESULT 的异常:0x8007007E)

c# html-to-pdf wkhtmltopdf .net-core dinktopdf

5
推荐指数
3
解决办法
2万
查看次数

将 HTML 转换为 PDF dink 到 pdf 时 CSS 转换和写入模式属性的问题

我正在尝试将 html 转换为 pdf,它在浏览器上运行良好,但是当我下载 pdf 时,css 属性、转换和写入模式不起作用。这是 css 代码示例。我正在使用 dinktopdf c# 库。

.left-content h2 {
        color: white;
        text-transform: uppercase;
        bottom: 65px;
        left: -25px;
        position: absolute;
        writing-mode: vertical-rl;
        transform: rotate(-90deg);
        text-orientation: mixed;
      }
Run Code Online (Sandbox Code Playgroud)

html css c# pdf dinktopdf

5
推荐指数
1
解决办法
1379
查看次数

使用 DinkToPdf 分隔分页符

我的 Program.cs 中有这个 C#:

    var page = "plain";

    var slnpath = $@"{Directory.GetCurrentDirectory()}\..\..\..\..";
    var htmlpath = $@"{slnpath}\HtmlTemplates\{page}.html";
    var pdfpath = $@"{slnpath}\PdfFiles\{page}.pdf";
    var dllpath = $@"{slnpath}\DinkNative64bit\libwkhtmltox.dll";

    var html = new StringBuilder(File.ReadAllText(htmlpath));

    var _converter = new SynchronizedConverter(new PdfTools());

    var context = new CustomAssemblyLoadContext().LoadUnmanagedLibrary(dllpath);

    var globalSettings = new GlobalSettings
    {
        ColorMode = ColorMode.Color,
        Orientation = Orientation.Portrait,
        PaperSize = PaperKind.A4,
        Margins = new MarginSettings { Top = 10 },
        DocumentTitle = "PDF Report",
        //Out = @"D:\PDFCreator\Employee_Report.pdf"  USE THIS PROPERTY TO SAVE PDF TO A PROVIDED …
Run Code Online (Sandbox Code Playgroud)

pdf-generation dinktopdf

4
推荐指数
1
解决办法
3975
查看次数

DinkToPDF PDF 生成在出现 502 错误之前只能在 Azure 上运行一次

我写了一个使用dinktopdf的 PDF 生成 API将一些模板化的 HTML 转换为字节数组。这一切在我的本地机器上运行良好,但是当我部署到我的 azure web 应用程序时,API 只能运行一次。当我第二次尝试时,我收到以下消息和 502 错误:

指定的 CGI 应用程序遇到错误,服务器终止了该进程。

这是我的代码的精简版本,仍然出现相同的错误:

static IPdfConverter pdfConverter = new SynchronizedConverter(new PdfTools());

public static byte[] BuildPdf(string html)
{
    return pdfConverter.Convert(new HtmlToPdfDocument()
    {
        Objects =
        {
            new ObjectSettings
            {
                HtmlContent = html
            }
        }
    });
}
Run Code Online (Sandbox Code Playgroud)

我还尝试使用IronPDF进行 HTML 到 PDF 的转换,并遇到了同样的问题(在本地机器上完美运行,但在 Azure 部署上只出现一次,然后出现一致的 502 错误)。

.net c# azure wkhtmltopdf dinktopdf

3
推荐指数
2
解决办法
1863
查看次数