gpt4 book ai didi

c# - IronPdf 打印到页边距

转载 作者:行者123 更新时间:2023-12-03 08:50:45 25 4
gpt4 key购买 nike

我尝试使用IronPdf打印pdf文件来自 html 但结果留下了边框。有没有办法在我的 PrintDocument 中设置“适合页面”?

这是我的代码:

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

最佳答案

感谢 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。

关于c# - IronPdf 打印到页边距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59179499/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com