Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

css printing exact size

Tags:

html

css

printing

UPD1. I have two printers:

  • a printer, thar prints stickers (EAN13 barcodes)44mm x 23mm
  • a default LaserJet printer (size A4)

I have two web-pages.

First page have a DIV with dimensions 44mm x 23mm setted in css:

@page {
    size: 40mm 23mm;
    overflow: hidden;
}

If I click in browser Print Preview I'd like to see only one page with exact width and height (44mm x 23 mm)

Second page have a DIV that have lot of data. It have to be restricted by width to A4 width, but may have multiple pages. If I click in browser Print Preview I wanna see A4-sized preview.

What browsers support this? Firefox 7 and Chrome 16.0.912 doesnt. Is it possible to print exactly what I want with exactly size I want in HTML5/CSS/etc...

like image 592
Lari13 Avatar asked Nov 02 '11 10:11

Lari13


1 Answers

I just gathered pieces from all over and put it altogether. It is working for me:

<html>
<head>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="http://barcode-coder.com/js/jquery-ui-1.7.custom.min.js"></script>
<script type="text/javascript" src="http://barcode-coder.com/dp.SyntaxHighlighter/Scripts/shCore.js"></script>
<script type="text/javascript" src="http://barcode-coder.com/dp.SyntaxHighlighter/Scripts/shBrushXml.js"></script>
<script type="text/javascript" src="http://barcode-coder.com/dp.SyntaxHighlighter/Scripts/shBrushJScript.js"></script>
<script type="text/javascript" src="http://barcode-coder.com/js/jquery-barcode-last.min.js"></script>

<script type="text/javascript">
    $(document).ready(function()
    {
        $("#ean").barcode("9785903979165", "ean13", {barWidth:2});
    });
</script>
<style>
#ean {
    position: absolute;
    left: 0;
    top: 0;
    width: 40mm;
    height: 23mm;
}

</style>
</head>
<body>
<div id="ean">
</div>
</body>
</html>
like image 150
Kangkan Avatar answered Oct 22 '22 16:10

Kangkan