0
私は人がページ上の画像を印刷するために印刷物をクリックできるようにしようとしています(複数の画像があるところ)。私は印刷することができますが、それは2ページで画像の左半分を示しています。ここでJSでRailsで印刷するときの画像サイズの調整方法は?
はERBです:
<a href="#" onclick="PrintImage('<%= image_path('image.jpg', size: "90x90") %>'); return false;">PRINT</a>
ここJSです:
<script type="text/javascript">
function ImagetoPrint(source) {
return "<html><head><script>function step1(){\n" +
"setTimeout('step2()', 10);}\n" +
"function step2(){window.print();window.close()}\n" +
"</scri" + "pt></head><body onload='step1()'>\n" +
"<img src='" + source + "' /></body></html>";
}
function PrintImage(source) {
Pagelink = "about:blank";
var pwa = window.open(Pagelink, "_new");
pwa.document.open();
pwa.document.write(ImagetoPrint(source));
pwa.document.close();
}
</script>
ERBでのサイズは動作しません。 max-height/max-widthのクラスを適用しようとしましたが、何も変化していません。私はimage_pathの代わりにimage_urlも使用しました。どちらも影響していません。
image_path/image_url内の画像のサイズを変更する方法はありますか?