【问题标题】:IronPdf Print to MarginIronPdf 打印到边距
【发布时间】:2019-12-04 15:32:23
【问题描述】:

我尝试从 html 打印带有 IronPdf 的 pdf,但结果留下了边框。 有没有办法在我的 PrintDocument 中设置 Fit-To-Page?

这是我的代码:

        public static void PrintDocument(string printer, bool landscape, PdfDocument pdfDocument, Duplexing duplex)
        {
            var printDocument = pdfDocument.GetPrintDocument();

            printDocument.PrinterSettings.PrinterName = printer;
            printDocument.DefaultPageSettings.Landscape = landscape;
            printDocument.PrinterSettings.Duplex = DuplexMapping(duplex);
            printDocument.PrinterSettings.DefaultPageSettings.PaperSize.RawKind = (int)PaperKind.A4;

            printDocument.Print();
        }

【问题讨论】:

    标签: c# printing printdocument ironpdf


    【解决方案1】:

    感谢 IronPdf-Support 我找到了解决方案:

                // enable javascript 
                var renderer = new IronPdf.HtmlToPdf();
                renderer.PrintOptions.EnableJavaScript = true;
                renderer.PrintOptions.RenderDelay = 500; //milliseconds
                renderer.PrintOptions.CssMediaType = IronPdf.PdfPrintOptions.PdfCssMediaType.Screen;
    
                renderer.PrintOptions.MarginTop = 0;
                renderer.PrintOptions.MarginBottom = 0;
                renderer.PrintOptions.MarginLeft = 0;
                renderer.PrintOptions.MarginRight = 0;
    

    将边距设置为 0。

    【讨论】:

    猜你喜欢
    • 2012-03-29
    • 1970-01-01
    • 2017-03-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多