#29612

//**************************************************<br /> // Get Pd4ml and rendering<br /> //***************************************************<br /> <br /> /*<br /> * Create Box styles<br /> */<br /> // [....]<br /> // Mail Text<br /> StringBuffer testoStyle = new StringBuffer("span.mailTextAddress {");<br /> testoStyle.append("position:absolute;");<br /> testoStyle.append("width: " + (width - testoMargineS - testoMargineD) + "mm;");<br /> testoStyle.append("top: " + testoMargineSup + "mm;");<br /> testoStyle.append("left: " + testoMargineS + "mm;");<br /> testoStyle.append("right: " + testoMargineD + "mm;");<br /> testoStyle.append("}");<br /> stili.add(testoStyle.toString());<br /> // Address Box<br /> StringBuffer boxAddressStyle = new StringBuffer("span.boxAddress {");<br /> boxAddressStyle.append(" width: " + pdfmlay.getPdfmIndDestiDimX().intValue() + "mm;");<br /> boxAddressStyle.append(" height: " + pdfmlay.getPdfmIndDestiDimY().intValue() + "mm;");<br /> boxAddressStyle.append("position: absolute;");<br /> boxAddressStyle.append("top:" + destMargineSup + "mm;");<br /> boxAddressStyle.append("left:" + destMargineSx + "mm;");<br /> boxAddressStyle.append("}");<br /> stili.add(boxAddressStyle.toString());<br /> <br /> // Create Pd4ml object<br /> PD4ML pd4ml = getPd4ml(sessionDo, PD4Constants.A4, stili.toArray(new String[stili.size()]), null, null);<br /> <br /> /*/*/<br /> InputStream is = new ByteArrayInputStream(input.getHTML().getBytes());<br /> InputStreamReader isr = new InputStreamReader(is);<br /> try {<br /> pd4ml.render(isr, outs1);<br /> ps = new PrintStream(outs);<br /> ps.write(outs1.toByteArray());<br /> outs.flush();<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 (ps != null) {<br /> ps.close();<br /> }<br /> }<br /> <br /> <br /> <br /> <br /> //**************************************************<br /> // Build Pd4ml<br /> //***************************************************<br /> public static PD4ML getPd4ml(MainSessionDo sessionDo, java.awt.Dimension pageSize, String[] styles, Rectangle myHeader, Rectangle myFooter)<br /> throws ErroreApplicativo {<br /> PD4ML pd4ml = new PD4ML();<br /> pd4ml.setPageInsets(new Insets(80, 40, 80, 60));<br /> <br /> pd4ml.setPageSize(pageSize); // landscape page orientation<br /> pd4ml.protectPhysicalUnitDimensions();<br /> pd4ml.setHtmlWidth(780);<br /> <br /> <br /> /* <hr class="bbcode_rule" /> Header <hr class="bbcode_rule" /> */<br /> PD4PageMark header = new PD4PageMark();<br /> ImgInfo infoH = getTempImg(sessionDo, input, "H", letpar); // get img header<br /> String dir = infoH.getImgPath();<br /> if (dir.trim().length() > 0) {<br /> dir = getFileHttpProtocol(dir, false);<br /> header.setAreaHeight(-1);<br /> <br /> if (myHeader == null) {<br /> myHeader = new Rectangle(infoH.getPosX().intValue(), infoH.getPosY().intValue(), infoH.getWidth().intValue(), infoH.getHeight().intValue());<br /> } else {<br /> if (infoH.getWidth().intValue() <= myHeader.getWidth() && infoH.getHeight().intValue() <= myHeader.getHeight())<br /> myHeader.setSize(infoH.getWidth().intValue(), infoH.getHeight().intValue());<br /> }<br /> header.setWatermark(dir, myHeader, 255);<br /> }<br /> /* <hr class="bbcode_rule" /> Footer <hr class="bbcode_rule" /> */<br /> PD4PageMark footer = new PD4PageMark();<br /> ImgInfo infoF = getTempImg(sessionDo, input, "F", letpar); // get img footer<br /> footer.setAreaHeight(-1);<br /> footer.setFontSize(20);<br /> footer.setPagesToSkip(1);<br /> footer.setTitleAlignment(PD4PageMark.RIGHT_ALIGN);<br /> footer.setPageNumberAlignment(PD4PageMark.LEFT_ALIGN);<br /> dir = infoF.getImgPath();<br /> if (dir.trim().length() > 0) {<br /> dir = getFileHttpProtocol(dir, false);<br /> <br /> if (myFooter == null) {<br /> myFooter = new Rectangle(infoF.getPosX().intValue(), infoF.getPosY().intValue(), infoF.getWidth().intValue(), infoF.getHeight().intValue());<br /> } else {<br /> if (infoH.getWidth().intValue() <= myFooter.getWidth() && infoH.getHeight().intValue() <= myFooter.getHeight())<br /> myFooter.setSize(infoH.getWidth().intValue(), infoH.getHeight().intValue());<br /> }<br /> footer.setWatermark(dir, myFooter, 255);<br /> }<br /> <br /> pd4ml.setPageHeader(header);<br /> pd4ml.setPageFooter(footer);<br /> <br /> // Add styles<br /> if (styles != null) {<br /> for (int i = 0; i < styles.length; i++) {<br /> if (styles<i> != null) {<br /> pd4ml.addStyle(styles<i>, true);<br /> }<br /> }<br /> }<br /> <br /> return pd4ml;<br /> }<br /> <br /> <br /> <br />