在HTTP协议上使用Pechkin时未加载样式和脚本

时间:2019-11-20 13:00:54

标签: c# wkhtmltopdf pechkin

我在pechkin的包装器C#中使用wkhtmltopdf库。使用http:协议可以很好地工作,但是使用https:时,脚本和样式不会以pdf格式加载。 预先感谢。

  

查看:

<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta charset="utf-8" />
    <link rel="icon" type="image/png" href="@Url.AbsoluteUrl("Content/Favicon/favicon.ico")" />

    @Styles.Render(Url.AbsoluteUrl("Content/themes/base/css"))
    @Styles.Render(Url.AbsoluteUrl("Content/themes/css"))
    @Scripts.Render(Url.AbsoluteUrl("Scripts/library"))
    @Scripts.Render(Url.AbsoluteUrl("Scripts/Common"))

</head>
<body>
    <div class="pad-none printBody size-100">
        <div class="tabs-nav">
            <div class="global-pad">
                <div class="row">
                    <div id="divReportGrids" class="size-100">
                        @string.Concat(AppConstants.Delimiters.StartDelimiter,
                               AppConstants.Common.PrintBodyPlaceholder,
                               AppConstants.Delimiters.EndDelimiter)
                    </div>
                </div>
            </div>
        </div>

    </div>

</body>
</html>
     

代码:

         var documentConfig = new ObjectConfig().SetZoomFactor(1)
                                                .SetScreenMediaType(true)
                                               .SetCreateExternalLinks(true)
                                                .SetAllowLocalContent(true)
                                                .SetLoadImages(true)
                                                .SetRunJavascript(true)
                                                .SetPrintBackground(true)
                                                .SetRenderDelay(10000);
        documentConfig.Footer.SetFont(new Font("Arial,Helvetica,sans-serif", 4F, FontStyle.Regular));
        documentConfig.Footer.SetRightText(@"[page] of [topage]");
        documentConfig.Footer.SetContentSpacing(5.00);

        var globalConfig = new GlobalConfig()
                    .SetDocumentTitle("POB Report")
                    .SetPaperSize(PaperKind.A4)
                    .SetOutputDpi(360);

        var pechkin = new SynchronizedPechkin(globalConfig);
        //Convert html to pdf
        byte[] htmlBytes = pechkin.Convert(documentConfig, completeHtml);

0 个答案:

没有答案