I have a problem with printing out HTML content. In details HTML is not scaled to fit the page and most of long line is cut off and rest of the line is wraped. I want to use print implementation from JTextComponent because I can pass footer element with page numbering.
Here is full code:
String line = "That's really long text line because it's containing one hundred character, so believe me it is long";
JEditorPane p = new JEditorPane();
p.setContentType("text/html");
StringBuilder htmlContent = new StringBuilder();
htmlContent.append("<html>");
htmlContent.append("<head>");
htmlContent.append("</head>");
htmlContent.append("<body>");
htmlContent.append("<table width = \"845\">");
htmlContent.append("<tr>");
htmlContent.append("<td>");
for(int i = 0 ; i < 100 ; i ++)
htmlContent.append("<font face=\"monospace\">" + line + "</font><br>");
htmlContent.append("</td>");
htmlContent.append("</tr>");
htmlContent.append("</table>");
htmlContent.append("</body>");
htmlContent.append("</html>");
MessageFormat footer = new MessageFormat(" Page #{0,number,integer}");
MessageFormat header = new MessageFormat("");
p.setText(htmlContent.toString());
p.print(header, footer, false, null, null, false);
Is there any way to force this print implementation to scale HTML content do page width?
Screenshot from my result (bottom of page):
I have tried also to make font smaller with adding size attribute to HTML font element. I have also tried to Override print method, but I don't know Swing components well and I have a problem with adding constant footer "near" the JEditorPane - in this case JEditorPane just takes all the printable area.
Thank you for any help.