Esempio n. 1
0
  /** 加入图片 */
  protected void processImage(Element parent, CharacterRun cr) {
    if (this.picstab.hasPicture(cr)) {
      Picture pic = picstab.extractPicture(cr, false);

      String fileName = pic.suggestFullFileName();
      OutputStream out = null;
      try {

        //					TWIPS_PER_INCH/
        out = new FileOutputStream(new File(output.concat(File.separator).concat(fileName)));
        pic.writeImageContent(out);
        Element img = htmlDocumentFacade.getDocument().createElement("img");
        String uri = fileName.concat("image").concat(File.separator).concat(fileName);
        img.setAttribute("src", uri);
        if (pic.getWidth() > 600) img.setAttribute("style", "width: 600px;");
        Element imgBlock = htmlDocumentFacade.createBlock();
        this.htmlDocumentFacade.addStyleClass(imgBlock, "imgs", "text-align:center;");
        imgBlock.appendChild(img);
        parent.appendChild(imgBlock);

      } catch (Exception e) {
        e.printStackTrace();
      } finally {
        if (out != null)
          try {
            out.close();
          } catch (IOException e) {
            e.printStackTrace();
          }
      }
    }
  } // 图片END
Esempio n. 2
0
 @Override
 protected void processImageWithoutPicturesManager(
     Element currentBlock, boolean inlined, Picture picture) {
   // no default implementation -- skip
   currentBlock.appendChild(
       htmlDocumentFacade.document.createComment(
           "Image link to '" + picture.suggestFullFileName() + "' can be here"));
 }