selectpdf html到pdf制作图像和页面相等大小
我用HTML生成一张卡,然后用SelectPDF转换器将其转换为PDF。问题是,我似乎无法完全适合卡和PDF页面,没有“白皮书”。 我的目标是卡和PDF页面的大小相同,因此我可以打印它。
代码(C#):
HtmlToPdf converter = new HtmlToPdf();
var doc = new PdfDocument();
converter.Options.PdfPageSize = PdfPageSize.Custom;
converter.Options.PdfPageCustomSize = new SizeF(Convert.ToInt32(paperWidth), Convert.ToInt32(paperHeight));
doc = converter.ConvertHtmlString(cardString);
return doc.Save();
I generate a card with html and then I convert it to pdf with SelectPdf converter. The problem is, I can't seem to fit the card and pdf page perfectly, without no "white paper".
My goal is that the card and pdf page are the same size, so i can print it.
the code (c#):
HtmlToPdf converter = new HtmlToPdf();
var doc = new PdfDocument();
converter.Options.PdfPageSize = PdfPageSize.Custom;
converter.Options.PdfPageCustomSize = new SizeF(Convert.ToInt32(paperWidth), Convert.ToInt32(paperHeight));
doc = converter.ConvertHtmlString(cardString);
return doc.Save();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用
div
元素,则在CSS中可以使用@Media
打印在打印时指定格式。如果您想了解更多信息,请阅读
If you use
div
element, in CSS you can use@media
print to specify formatting when printed.If you want to know more , read this