#29611

Hi,
I’ll post another error example.
I’m trying to print a pdf with 100 lines, a header and a footer.
Some lines (n 33, 85) are not printed and the text overwrite header and footer.
Any idea??

<br /> import it.solarisistemi.base.ErroreApplicativo;<br /> import it.solarisistemi.base.logs.LogEntry;<br /> <br /> import java.awt.Insets;<br /> import java.awt.Rectangle;<br /> import java.io.ByteArrayInputStream;<br /> import java.io.ByteArrayOutputStream;<br /> import java.io.File;<br /> import java.io.FileOutputStream;<br /> import java.io.IOException;<br /> import java.io.InputStream;<br /> import java.io.InputStreamReader;<br /> import java.io.PrintStream;<br /> import java.security.InvalidParameterException;<br /> import java.util.ArrayList;<br /> <br /> import org.zefer.pd4ml.PD4Constants;<br /> import org.zefer.pd4ml.PD4ML;<br /> import org.zefer.pd4ml.PD4PageMark;<br /> <br /> public class ProvaPD4ML {<br /> <br /> public static void main(String[] args) throws ErroreApplicativo {<br /> PD4ML pd4ml = new PD4ML();<br /> <br /> pd4ml.setPageInsetsMM(new Insets(15, 0, 15, 0));<br /> <br /> pd4ml.setPageSize(PD4Constants.A4); // landscape page orientation<br /> pd4ml.protectPhysicalUnitDimensions();<br /> pd4ml.setHtmlWidth(780);<br /> <br /> /* <hr class="bbcode_rule" /> Header <hr class="bbcode_rule" /> */<br /> PD4PageMark header = new PD4PageMark();<br /> header.setAreaHeight(-1);<br /> header.setFontSize(20);<br /> header.setPagesToSkip(1);<br /> String dir = getFileHttpProtocol(getImgTempPath(), true);<br /> header.setWatermark(dir, new Rectangle(10, 10, 200, 100), 255);<br /> <br /> /* <hr class="bbcode_rule" /> Footer <hr class="bbcode_rule" /> */<br /> PD4PageMark footer = new PD4PageMark();<br /> footer.setAreaHeight(-1);<br /> footer.setFontSize(20);<br /> footer.setPagesToSkip(1);<br /> footer.setWatermark(dir, new Rectangle(10, 700, 200, 100), 255);<br /> <br /> pd4ml.setPageHeader(header);<br /> pd4ml.setPageFooter(footer);<br /> <br /> ArrayList<String> styles = new ArrayList<String>();<br /> <br /> StringBuffer pageStyle = new StringBuffer("span.indirizzo {");<br /> pageStyle.append("position: absolute; top: 50mm; left: 120mm;");<br /> pageStyle.append("border: 1px solid red;");<br /> pageStyle.append("}");<br /> styles.add(pageStyle.toString());<br /> <br /> pageStyle = new StringBuffer("span.lettera {");<br /> pageStyle.append("position: absolute; top: 90mm; left: 15mm;");<br /> pageStyle.append("border: 1px solid blue;");<br /> pageStyle.append("}");<br /> styles.add(pageStyle.toString());<br /> <br /> if (styles != null) {<br /> <br /> for (int i = 0; i < styles.size(); i++) {<br /> if (styles.get(i) != null) {<br /> pd4ml.addStyle(styles.get(i), true);<br /> }<br /> }<br /> }<br /> <br /> StringBuffer letteraHtml = new StringBuffer("");<br /> letteraHtml.append("<span class='indirizzo'>");<br /> letteraHtml.append("SOLARI SISTEMI");<br /> letteraHtml.append("<br /> VIA CREMONA, 10");<br /> letteraHtml.append("<br /> 25025 BRESCIA BS");<br /> letteraHtml.append("</span>");<br /> <br /> letteraHtml.append("<span class='lettera'>");<br /> for (int i = 0; i < 100; i++) {<br /> letteraHtml.append("<br /> LoremIposum " + i);<br /> }<br /> letteraHtml.append("</span>");<br /> <br /> InputStream is = new ByteArrayInputStream(letteraHtml.toString().getBytes());<br /> InputStreamReader isr = new InputStreamReader(is);<br /> <br /> FileOutputStream outs = null;<br /> PrintStream ps = null;<br /> ByteArrayOutputStream outs1 = new ByteArrayOutputStream(16000);<br /> <br /> try {<br /> File myfile = new File("C:\tmp\pd4ml.pdf");<br /> if (myfile.exists()) {<br /> myfile.delete();<br /> myfile = new File("C:\tmp\pd4ml.pdf");<br /> }<br /> <br /> outs = new FileOutputStream(myfile);<br /> ps = new PrintStream(outs);<br /> <br /> pd4ml.render(isr, outs1);<br /> ps = new PrintStream(outs);<br /> ps.write(outs1.toByteArray());<br /> outs.flush();<br /> System.out.println("Fine");<br /> <br /> } catch (InvalidParameterException e) {<br /> e.printStackTrace();<br /> throw new ErroreApplicativo(e);<br /> } catch (IOException e) {<br /> e.printStackTrace();<br /> throw new ErroreApplicativo(e);<br /> } finally {<br /> if (outs != null) {<br /> try {<br /> outs.close();<br /> } catch (IOException e) {<br /> ;<br /> }<br /> }<br /> if (ps != null) {<br /> ps.close();<br /> }<br /> }<br /> <br /> }<br /> <br /> public static String getFileHttpProtocol(String path, boolean utfUrlEncode) {<br /> String url = path.replace(':', '|').replaceAll("/", File.separator).replaceAll("\\", "\\\\");<br /> url = "file:///" + url;<br /> return url.trim();<br /> }<br /> <br /> public static String getImgTempPath() {<br /> String path = "";<br /> <br /> String tempDir = System.getProperty("java.io.tmpdir");<br /> LogEntry.debug("PDFI - System temp directory :: " + tempDir);<br /> File fileTemp = new File(tempDir + File.separatorChar + "solari.png");<br /> if (fileTemp.exists()) {<br /> path = fileTemp.getAbsolutePath();<br /> }<br /> return path.trim();<br /> }<br /> <br /> }<br /> <br />