edabg / jsprintsetup

JSPrintSetup Firefox addon
Mozilla Public License 2.0
77 stars 39 forks source link

Force page break #47

Open v-bubar opened 7 years ago

v-bubar commented 7 years ago

Is it possible to force a page break on a specific spot? Right now i'm doing something like that:

<style>
    .card_layout {
        width: 86mm;
        height: 54mm;
    }
    .card_name {
        font-weight: 900;
        font-size: 25px;
    }
    .card_text {
        margin-left: 5mm;
        margin-top: 25mm;
    }
    @media print {
        .breaker {
            page-break-after: always;
        }
    }
</style>
    <div class="card_layout breaker">
        <div class="card_text">
            <div class="card_name" id="card_name">Name</div>
            <div class="card_company" id="card_company">Company</div>
        </div>
    </div>
    <div class="card_layout">
        <div class="card_text">
            <div class="card_name" id="card_name">Name</div>
            <div class="card_company" id="card_company">Company</div>
        </div>
    </div>
<script>
 jsPrintSetup.setPrinter('Evolis Primacy');
            jsPrintSetup.setPaperSizeUnit(jsPrintSetup.kPaperSizeMillimeters);
            jsPrintSetup.setOption('paperWidth', 86);
            jsPrintSetup.setOption('paperHeight',54);

            jsPrintSetup.setOption('marginTop', 0);
            jsPrintSetup.setOption('marginBottom', 0);
            jsPrintSetup.setOption('marginLeft', 0);
            jsPrintSetup.setOption('marginRight', 0);

            jsPrintSetup.setOption('headerStrLeft', '');
            jsPrintSetup.setOption('headerStrCenter', '');
            jsPrintSetup.setOption('headerStrRight', '');

            jsPrintSetup.setOption('footerStrLeft', '');
            jsPrintSetup.setOption('footerStrCenter', '');
            jsPrintSetup.setOption('footerStrRight', '');

            jsPrintSetup.saveOptions('kSaveAll');

            jsPrintSetup.clearSilentPrint();

            jsPrintSetup.setOption('printSilent', 1);

            jsPrintSetup.print();
</script>

The idea is to break a page after the first div.card_layout. However both divs are printed on the same page. Am I doing something wrong?

I'm testing the code on 54.0.1, OS X 10.11.

Thank you in advance for your answer.