Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

HTML & CSS Set printer settings to print label

AdyUPL

New Coder
Hi,
Where i have mistake?
I try set print friendly page to print label.

It's work when i edit printer settings before print.
How i can set this from this page?


HTML:
<style type="text/css">
body {
    margin: 0;
    padding: 0;
    background-color: #FAFAFA;
    font: 8pt "Arial";
    font-weight:bold;
    text-align: center;
}
@page {
    margin: 0mm;
    size: 50mm 30mm portrait;
}

* {
    box-sizing: border-box;
    -moz-box-sizing: border-box;
}
.page {
    margin: auto;
    border: 1px #D3D3D3 solid;
    border-radius: 5px;
    background: white;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);

}
@media print {
    .page {
        margin: auto;
        border: none;
        border-radius: none;
        box-shadow: none;
        background: initial;
        page-break-after: always;
    }
}

#img{
    transform:scale(0.6,0.6) translate(-20%,-3px);;
}
</style>
<div style="max-width: 50mm;max-height: 30mm;">
<div class="page">
Data przyjęcia: {{{value DataPrzyj}}}<br>
Nr: {{{value NrInw}}}<br>
{{{value Nazwa}}}
<div id="img">{{{value KodKres2}}}</div>
{{{value KodKres}}}
</div>
</div>
 

Attachments

  • Printer setting.png
    Printer setting.png
    39.2 KB · Views: 11
  • Label.png
    Label.png
    4.1 KB · Views: 11
I had not seen your initial post. It seems you are still looking for a solution ?
If I understand correctly you want to set, from within your page, the label size and margins in the Printer Preferences of your label printer ? I don't think that is possible, but perhaps someone else here knows more. Anyway, I do not understand why this should be necessary. If you set the parameters correctly in your Printer Preferences, surely it will be remembered for the next time, and there would be no need to worry about it ever again ? Or do the settings change back to the wrong values every time ? If so, that is what you need to look into, instead of trying to change it programmatically. Unless of course you use the same printer for different sizes of labels ?
 

Buy us a coffee!

Back
Top Bottom