Stupi / flying-saucer

Automatically exported from code.google.com/p/flying-saucer
0 stars 0 forks source link

Footers are not printed using XHTMLPrintable #154

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Using the html below with the defind CSS @page directives; pages are printed 
without the defined footer.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html;charset=ISO-8859-1" />
<meta http-equiv="date" content="Fri, 24 Jun 2011 17:13:38 CEST" />
<title>Change Report</title>
<style type="text/css" media="print">
h1 {font-family: Lucida Sans, sans-serif; font-weight: bold; color: #339966;}
@page {
    @bottom-center {
        font-family: Lucida Bright; font-size:70%; font-style:italic; 
        content: "&#169; Cressida Technology Ltd. 2011";
    }
    @bottom-right {
        font-family: Lucida Bright; font-size:70%;
        content: "Page " counter(page);
    }
}
@page { size: 8.27in 11.69in;
    margin: 1in 1in 1in 1in; }
</style>
</head>
<body>
<h1>Dette er en prøve</h1>
<h1 style="page-break-before:always;" >Dette skulle v&#230;re p&#229; side 
2</h1>
</body>
</html>

public void print(boolean preview) {
    XHTMLPanel panel = new XHTMLPanel();
    panel.setDocumentFromString(html.toString(), null, new XhtmlNamespaceHandler());
    panel.getSharedContext().setPrint(true);
    panel.getSharedContext().setInteractive(false);
    panel.relayout();
    PrinterJob job = PrinterJob.getPrinterJob();
    job.setPrintable(new XHTMLPrintable(panel));
    if (preview) {
        JDialog d = new JDialog((Frame) null, true);
        d.setSize(600, 400);
        JScrollPane sp = new JScrollPane();
        sp.setViewportView(panel);
        d.getContentPane().add(sp);
        d.setVisible(true);
    }
    if (job.printDialog())
        try {
            job.print();
        } catch (PrinterException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
}

Previewing the XHTMLPanel nicely shows both footer.

For your additional info: The font size in the printout differs from the font 
size on screen, making text on page two wrap into two lines.

Christian

Original issue reported on code.google.com by Christia...@gmail.com on 24 Jun 2011 at 3:26