コード例 #1
0
 /**
  * Change the textMode() to either SHAPE or MODEL. <br>
  * This resets all renderer settings, and should therefore be called <EM>before</EM> any other
  * commands that set the fill() or the textFont() or anything. Unlike other renderers, use
  * textMode() directly after the size() command.
  */
 public void textMode(int mode) {
   if (textMode != mode) {
     if (mode == SHAPE) {
       g2.dispose();
       g2 = content.createGraphicsShapes(width, height);
     } else if (mode == MODEL) {
       g2.dispose();
       g2 = content.createGraphics(width, height, mapper);
       //        g2 = template.createGraphics(width, height, mapper);
     } else if (mode == SCREEN) {
       throw new RuntimeException("textMode(SCREEN) not supported with PDF");
     } else {
       throw new RuntimeException("That textMode() does not exist");
     }
   }
 }
コード例 #2
0
  /** Call to explicitly go to the next page from within a single draw(). */
  public void nextPage() {
    PStyle savedStyle = getStyle();
    g2.dispose();

    try {
      //    writer.setPageEmpty(false);  // maybe useful later
      document.newPage(); // is this bad if no addl pages are made?
    } catch (Exception e) {
      e.printStackTrace();
    }
    if (textMode == SHAPE) {
      g2 = content.createGraphicsShapes(width, height);
    } else if (textMode == MODEL) {
      g2 = content.createGraphics(width, height, mapper);
    }
    style(savedStyle);

    // should there be a beginDraw/endDraw in here?
  }
コード例 #3
0
ファイル: MetaDoPS.java プロジェクト: pinnymz/pdftk_ext
  public void readAll() throws IOException, DocumentException {

    cb.saveState();
    java.awt.Graphics2D g2 = cb.createGraphicsShapes(PageSize.A4.width(), PageSize.A4.height());
    try {
      PAContext context =
          new PAContext(
              (Graphics2D) g2,
              new Dimension((int) PageSize.A4.width(), (int) PageSize.A4.height()));
      context.draw(new BufferedInputStream(in));
      // ( (Graphics2D) backBuffer.getGraphics()).dispose();
      in.close();
    } catch (IOException ex) {
      ex.printStackTrace();
    } catch (PainterException ex) {
      ex.printStackTrace();
    }

    cb.restoreState();
  }