我尝试使用html中的IronPdf打印pdf,但结果留下了边框。 有没有办法在我的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();
}
答案 0 :(得分:0)
感谢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。