0
When I send a form to print it changes the size according to the size of the page, in my case it is a card 54mm wide and 84mm high, I put these measurements in my code. It creates the page, I can isolate the cards, problem that it auto-resizes to the size of the sheet, then it happens that when I pick up the A4 printer it gets a size, when I put in the card it gets really small... I’m using media print to do what I need.
<!DOCTYPE html>
<html>
<head>
<title>Consulta Código - Resposta</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
<style type="text/css">
@media print
{
* {-webkit-print-color-adjust:exact;}
}
@media print {
body * {
visibility: hidden;
}
#printable, #printable * {
visibility: visible;
}
}
</style>
</head>
<body>
<div class="container" style="margin-top: 120px;margin-left: 120px">
<form id="printable" style="width: 5.4cm;height: 8.4cm;background-image: url(imagens/teste.png); background-size: 5.4cm 8.4cm">
<div class="form-group" style="padding-top: 4.3cm;">
<!-- <img src="data:image/jpeg;base64,<br />
<b>Notice</b>: Undefined variable: imagem in <b>C:\xampp\htdocs\cracha\consulta.php</b> on line <b>169</b><br />
" width="145" height="179" style="border-radius: 7px"/><br> -->
<center><p style='font-size: 20px'><b>FALABRETTI </b></p></center>
<center><p style='font-size: 11px;margin-top: -20px;padding-left: 5px'><b>DIRCE LOURDES FALABRETTI </b></p></center>
<!-- <div align="center" >
<img src=p.gif width=3 height=46 border=0><img
src=b.gif width=3 height=46 border=0><img
src=p.gif width=3 height=46 border=0><img
src=b.gif width=3 height=46 border=0><img
src=p.gif width=3 height=46 border=0><img
src=b.gif width=3 height=46 border=0><img src=p.gif width=5 height=46 border=0><img
src=b.gif width=3 height=46 border=0><img src=p.gif width=3 height=46 border=0><img
src=b.gif width=5 height=46 border=0><img src=p.gif width=5 height=46 border=0><img
src=b.gif width=5 height=46 border=0><img src=p.gif width=3 height=46 border=0><img
src=b.gif width=3 height=46 border=0><img src=p.gif width=3 height=46 border=0><img
src=b.gif width=5 height=46 border=0><img src=p.gif width=5 height=46 border=0><img
src=b.gif width=3 height=46 border=0><img src=p.gif width=3 height=46 border=0><img
src=b.gif width=5 height=46 border=0><img src=p.gif width=3 height=46 border=0><img
src=b.gif width=3 height=46 border=0><img src=p.gif width=5 height=46 border=0><img
src=b.gif width=3 height=46 border=0><img src=p.gif width=3 height=46 border=0><img
src=b.gif width=3 height=46 border=0><img src=p.gif width=5 height=46 border=0><img
src=b.gif width=3 height=46 border=0><img src=p.gif width=5 height=46 border=0><img
src=b.gif width=3 height=46 border=0><img src=p.gif width=3 height=46 border=0><img
src=b.gif width=5 height=46 border=0><img src=p.gif width=3 height=46 border=0><img
src=b.gif width=5 height=46 border=0><img src=p.gif width=5 height=46 border=0><img src=b.gif width=3 height=46 border=0><img
src=p.gif width=1 height=46 border=0> </div> -->
</div>
</form>
</div>
<div class="container" style="margin-top: 50px; margin-left: 120px">
<form style="width: 5.7cm;height: 9cm;background-image: url(imagens/teste2.png); background-size: 5.7cm 9cm; ">
<div class="form-group" style="padding-top: 7.2cm">
<!-- <img src="data:image/jpeg;base64,<br />
<b>Notice</b>: Undefined variable: imagem in <b>C:\xampp\htdocs\cracha\consulta.php</b> on line <b>225</b><br />
" width="145" height="179" style="border-radius: 7px"/><br> -->
<!--<center><p style='font-size: 20px'><b>FALABRETTI </b></p></center>
<p style='font-size: 12px;margin-top: -15px;padding-left: 37px'><b>DIRCE LOURDES FALABRETTI </b></p> -->
<div align="center" >
<img src=p.gif width=3 height=46 border=0><img
src=b.gif width=3 height=46 border=0><img
src=p.gif width=3 height=46 border=0><img
src=b.gif width=3 height=46 border=0><img
src=p.gif width=3 height=46 border=0><img
src=b.gif width=3 height=46 border=0><img src=p.gif width=3 height=46 border=0><img
src=b.gif width=5 height=46 border=0><img src=p.gif width=5 height=46 border=0><img
src=b.gif width=3 height=46 border=0><img src=p.gif width=5 height=46 border=0><img
src=b.gif width=5 height=46 border=0><img src=p.gif width=3 height=46 border=0><img
src=b.gif width=3 height=46 border=0><img src=p.gif width=3 height=46 border=0><img
src=b.gif width=3 height=46 border=0><img src=p.gif width=3 height=46 border=0><img
src=b.gif width=5 height=46 border=0><img src=p.gif width=5 height=46 border=0><img
src=b.gif width=3 height=46 border=0><img src=p.gif width=5 height=46 border=0><img
src=b.gif width=3 height=46 border=0><img src=p.gif width=3 height=46 border=0><img
src=b.gif width=5 height=46 border=0><img src=p.gif width=5 height=46 border=0><img
src=b.gif width=3 height=46 border=0><img src=p.gif width=3 height=46 border=0><img
src=b.gif width=5 height=46 border=0><img src=p.gif width=5 height=46 border=0><img
src=b.gif width=5 height=46 border=0><img src=p.gif width=3 height=46 border=0><img
src=b.gif width=3 height=46 border=0><img src=p.gif width=3 height=46 border=0><img
src=b.gif width=3 height=46 border=0><img src=p.gif width=3 height=46 border=0><img
src=b.gif width=3 height=46 border=0><img src=p.gif width=3 height=46 border=0><img
src=b.gif width=3 height=46 border=0><img src=p.gif width=3 height=46 border=0><img
src=b.gif width=3 height=46 border=0><img src=p.gif width=5 height=46 border=0><img
src=b.gif width=5 height=46 border=0><img src=p.gif width=5 height=46 border=0><img
src=b.gif width=5 height=46 border=0><img src=p.gif width=5 height=46 border=0><img src=b.gif width=3 height=46 border=0><img
src=p.gif width=1 height=46 border=0> </div>
<center style='margin-top: -7px'><font style='font-size: 9px;color:#000000;font-family:Tahoma;'>902567 </font></center>
</div>
</form>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js" integrity="sha384-wHAiFfRlMFy6i5SRaxvfOCifBUQy1xHdJ/yoi7FRNXMRBu5WHdZYu1hA6ZOblgut" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" crossorigin="anonymous"></script>
</body>
</html>
I do not know if it will solve, but change everything with measures in % to px or mm inside
@media print
and run a test. You don’t have to face your original file, create a separate HTML with only one element in % width and another in PX or MM, then in@media print
vc inverts the % and PX MM and simulates the printing to see what happens. It’s just a tip anyway, now you can’t stop to test it here. If it works this method comments there :)– hugocsl
I tried to do what you said (if I got it right), I’ll put all my code in the question
– Ricardo Goncalves
Cara opens this page in the browser and edits his question with the code already rendered in the browser. Go there from a Ctrl+U and take the code and paste it here. And code like you posted makes it hard for us to do the tests etc.
– hugocsl
Okay, I changed the code
– Ricardo Goncalves
is it possible to @hugocsl transform everything from form to image? So it saves the image in the right size and dps have the image printed, know how to do this?
– Ricardo Goncalves
Dude I think with some API in PHP or Python you can capture a "print" screen and maybe already open for printing. Something else. I think this size change might be because your printer’s config is to "adjust media to the printing area" or something. The problem with Print is that through the browser we cannot change the configs of the user’s printer. I don’t think I can help you much more... But take a look at this article that sometimes has something that interests you https://www.smashingmagazine.com/2018/05/print-stylesheets-in-2018/
– hugocsl