将网页的一部分转换为pdf/图像格式并在asp.net中打印 [英] convert a part of web page into pdf/image format and print in asp.net
本文介绍了将网页的一部分转换为pdf/图像格式并在asp.net中打印的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想打印一部分网页.我正在使用以下javascript函数进行打印:
Hi,
I want to print a portion of webpage. I''m using the following javascript function to print:
<script language="javascript">
function PrintPartOfTheWebPage()
{
var prtContent = document.getElementById("print");
var windowUrl = 'about:blank';
var WinPrint = window.open('','','letf=0,top=0,width=212,height=337,location=top,scrollbars=0,status=0');
WinPrint.document.write(prtContent.innerHTML);
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();
prtContent.innerHTML = "";
}
</script>
我想在左上角打印它,而没有任何边距或页眉和页脚.另外,在打印输出中没有打印背景色时.
那么我可以将div部分转换为图像或pdf格式并发送到打印机吗?
我该怎么办?
谢谢.
I want to print it in the top left corner without any margins or header&footer. Also, while printing background color is not coming in the printout.
So can I convert the div portion into an image or pdf format and send to printer?
How can I do it?
Thank you.
推荐答案
在这里,您将进行类似的讨论&文章.
从网页上打印PDF [ ^ ]
http://stackoverflow.com/questions/1686280/convert- html-having-javascript-to-pdf-using-java-javascript [
Hi,
Here you go with similar discussion & articles.
Printing a PDF from a web page[^]
http://stackoverflow.com/questions/1686280/convert-html-having-javascript-to-pdf-using-java-javascript[^]
Hope it helps.
--Amit
像这样尝试
try like this
function PrintContent() {
var DocumentContainer = document.getElementById(''divPrint'');
var WindowObject = window.open('''', ''PrintWindow'', ''width=750,height=650,top=50,left=50,toolbars=no,scrollbars=yes,status=no,resizable=yes'');
var strHtml = "<html>\n<head>\n<link rel=\"stylesheet\" type=\"text/css\" href=\"print.css\">\n</head><body><h4>\n<div style=\"testStyle \">\n" + DocumentContainer.innerHTML + "\n</div>\n</body>\n</html>";
WindowObject.document.writeln(strHtml);
WindowObject.document.close();
WindowObject.focus();
//WindowObject.print();
// WindowObject.close();
}
其中print.css是包含页面样式的样式表.相应地修改样式表
试试这个
where print.css is the stylesheet containing your style for the page.Modify your stylesheet accordingly
Try this
这篇关于将网页的一部分转换为pdf/图像格式并在asp.net中打印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文