Resize images with Print.Window

1

I have a function that takes print from an image to be able to print it. But I would like to know if you can change the position of this image at the time it enters the method.

function thus opens the image

I would like to resize the image 90º to the right in order to get the sheet (A4 size), is it possible?

Follow the code below:

function printPartOfPage(elementId) {
           var printContent = document.getElementById(elementId);
            var printWindow = window.open('', '', 'left=10,top=10,width=740,height=600');

            printWindow.document.write(printContent.innerHTML);
            printWindow.document.close();
            printWindow.focus();
            printWindow.print();
            printWindow.close();
        }
    
asked by anonymous 04.06.2018 / 22:27

1 answer

1

Igor in the CSS of your page you can make a style to change the orientation of the sheet just at the time of printing this way.

@page {
  size: A4 landscape;
}

Maybe you have to adapt your JS to call this css if you do not use css in the project.

See a practical example:

html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
}
div {
    width: 90%;
}
@page {
  size: landscape;
}
<div>
    <img src='http://unsplash.it/600/280' style="width: 100%;" alt="">
</div>

With this example above I got these results

COM @page size: landscape

SEM@pagesize

HereyouhaveMozilladocumentationon@page link

    
04.06.2018 / 23:06
Nuget Paint Package or Digital Signature ___ ___ erkimt Div does not fit the screen ______ qstntxt ___

On the

link

I use the plugin animate link

So the array of %code% is thus by default

%pre%

While the site is screen beauty

But when you're on mobile, one of the %code% , which I can not identify, is too long ( %code% ).

Iwouldliketomake%code%havetheheightofyourinterior!

Howtodothisforsmallerscreens?

ButtheproblemisthatIcouldnotidentifywheretochange!

    
______azszpr304340___

Your problem is that you are using a %code% in the Mobile version that is too large. in your @media makes a rule to remove this %code% . See below in the image to see how I fixed the bug.

OBS: See in the Chrome DevTools panel that I remove from %code% o %code%

    
___