View Full Version : اعمال استایل مورد نظر در پرینت (محتوای یه پنل)
bftarane
شنبه 07 بهمن 1391, 00:47 صبح
سلام.
من با استفاده از لینک زیر
http://www.aspsnippets.com/Articles/Print-ASPNet-Panel-contents-with-Print-Preview-using-JavaScript.aspx
از محتوای panel پرینت می گیرم
منتها مشکلی که وجود داره اینه که مثلاً صفحه من rtl هست ولی در پرینت ltr نشون داده میشه
حالا چطور می تونم استایل مورد نظرم رو به صفحه پرینت اعمال کنم؟
در عکس های زیر می تونید منظور من رو بهتر متوجه بشید
99007
99008
Mohsen.
شنبه 07 بهمن 1391, 01:18 صبح
کد زیر رو امتحان کنید.
@media print{
*{
direction: rtl;
}
}
کلا داخل media print@ هر چی بنویسید زمان چاپ اعمال میشه.
bftarane
یک شنبه 08 بهمن 1391, 11:14 صبح
سلام کد بالا جواب نداد
بچه ها راه دیگه ای به نظرتون نمی رسه؟
فکر میکنم کد بالا زمانی جواب میده که محتوای کل صفحه داره پرینت گرفته میشه ولی اینجا من دارم محتوای یه پنل رو پرینت می گیرم.
tamafi6
یک شنبه 08 بهمن 1391, 14:08 عصر
ازکدزیراستفاده کنید
@media print {
* {
direction: rtl;
background: none !important;
color: black !important;
box-shadow: none !important;
text-shadow: none !important;
/* Images, vectors and such */
filter: Gray(); /* IE4-8: depreciated */
filter: url('desaturate.svg#grayscale'); /* SVG version for IE10, Firefox, Safari 5 and Opera */
-webkit-filter: grayscale(100%); /* Chrome + Safari 6 */
-moz-filter: grayscale(100%); /* Future proof */
-ms-filter: grayscale(100%); /* Future proof */
-o-filter: grayscale(100%); /* Future proof */
filter: grayscale(100%); /* Future proof or polyfilled */
}
a {
text-decoration: underline;
}
a[href]:after {
content: " (" attr(href) ")";
}
a[href="#"],
a[href="javascript:"] {
content: "";
}
}
2undercover
یک شنبه 08 بهمن 1391, 14:54 عصر
این اسکریپت میاد و محتویات div رو در یک pop-op قرار میده و از اون pop-op پرینت می گیره واسه همین اون کد های دوستان عمل نمی کنه...!
bftarane
دوشنبه 09 بهمن 1391, 17:35 عصر
خوب الآن چه راهی پیشنهاد می کنید چه طوری می تونم به اون پنل استایل اعمال کنم؟
<script type = "text/javascript"> function PrintPanel() {
var panel = document.getElementById("<%=pnlContents.ClientID %>");
var printWindow = window.open('', '', 'height=400,width=800');
printWindow.document.write('<html><head><title>DIV Contents</title>');
printWindow.document.write('</head><body >');
printWindow.document.write(panel.innerHTML);
printWindow.document.write('</body></html>');
printWindow.document.close();
setTimeout(function () {
printWindow.print();
}, 500);
return false;
}
</script>
2undercover
سه شنبه 10 بهمن 1391, 06:23 صبح
<script type = "text/javascript"> function PrintPanel() {
var panel = document.getElementById("<%=pnlContents.ClientID %>");
var printWindow = window.open('', '', 'height=400,width=800');
printWindow.document.write('<html><head><title>DIV Contents</title>');
printWindow.document.write('<link rel="stylesheet" media="print" href="print.css"></head><body >');
printWindow.document.write(panel.innerHTML);
printWindow.document.write('</body></html>');
printWindow.document.close();
setTimeout(function () {
printWindow.print();
}, 500);
return false;
}
</script>
فقط کافیه توی اون قسمت که محتوا رو توی اون پنجریه می نویسه یعنی document.write() بگید که استایل های CSS رو هم توی پنجره جدید بنویسه یعنی اینجوری:printWindow.document.write('<link rel="stylesheet" media="print" href="print.css"></head><body >');
vBulletin® v4.2.5, Copyright ©2000-1404, Jelsoft Enterprises Ltd.