Package com.itextpdf.text.pdf

Examples of com.itextpdf.text.pdf.PdfContentByte$UncoloredPattern


        System.out.println("Input page size: " + pageSize);
        Document doc = new Document(PageSize.A4.rotate(), 0, 0, 0, 0);
        PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream(output));
        doc.open();
        // splitLine(doc, writer);
        PdfContentByte cb = writer.getDirectContent();
        float bottom = (doc.top() - pageSize.getHeight()) / 2 + kOffset;
        float left = doc.right() / 2 - (pageSize.getWidth() + kTextWidth) / 2 - kMargin;
        float right = doc.right() / 2 - (pageSize.getWidth() - kTextWidth) / 2 + kMargin;

        for (int i = 0; i <= n;) {
            PdfImportedPage page = getPage(writer, reader, i++);
            if (page != null)
                cb.addTemplate(page, left, bottom);

            page = getPage(writer, reader, i++);
            if (page != null)
                cb.addTemplate(page, right, bottom);

            doc.newPage();
        }
        doc.close();
    }
View Full Code Here


        }
        doc.close();
    }

    private static void splitLine(Document doc, PdfWriter writer) {
        PdfContentByte cb = writer.getDirectContentUnder();
        cb.moveTo(doc.right() / 2, doc.bottom());
        cb.lineTo(doc.right() / 2, doc.top());
        cb.stroke();
    }
View Full Code Here

            pages[i++] = y--;
            pages[i++] = x++;
            pages[i++] = x++;
            pages[i++] = y--;
        }
        PdfContentByte cb = writer.getDirectContent();
        float bottom = (doc.top() - pageSize.getHeight()) / 2 + kOffset;
        float left = doc.right() / 2 - (pageSize.getWidth() + kTextWidth) / 2 - kMargin;
        float right = doc.right() / 2 - (pageSize.getWidth() - kTextWidth) / 2 + kMargin;

        for (int i = 0; i < pages.length;) {
            PdfImportedPage page = getPage(writer, reader, pages[i++]);
            if (page != null)
                cb.addTemplate(page, left, bottom);

            page = getPage(writer, reader, pages[i++]);
            if (page != null)
                cb.addTemplate(page, right, bottom);

            doc.newPage();
        }
        doc.close();
    }
View Full Code Here

   * @throws BadElementException
   *             on error
   * @throws IOException
   */
  public static Image getInstance(final PdfWriter writer, final java.awt.Image awtImage, final float quality) throws BadElementException, IOException {
    return getInstance(new PdfContentByte(writer), awtImage, quality);
  }
View Full Code Here

      PdfReader reader = new PdfReader(
          pfad  );

      PdfImportedPage page = writer.getImportedPage(reader, 1);

      PdfContentByte cb = writer.getDirectContent();
      cb.addTemplate(page, 0, 0);

      doHeader();

      doParagraph(trip, forUser);
View Full Code Here

    private void addPageSizeEnforcer(PdfWriter writer) {
        if (marginEnforcerImage == null) {
            marginEnforcerImage = createEnforcerImage();
        }
        PdfContentByte cb = writer.getDirectContent();
        Rectangle pageSize = writer.getPageSize();
        try {
            float sz = 2.5f;
            float dx = pageSize.getWidth() - sz;
            float dy = pageSize.getHeight() - sz;
            cb.addImage(marginEnforcerImage, sz, 0, 0, sz, 0, dy);
            cb.addImage(marginEnforcerImage, 0, sz, -sz, 0, sz, 0);
            cb.addImage(marginEnforcerImage, -sz, 0, 0, -sz, dx + sz, sz);
            cb.addImage(marginEnforcerImage, 0, -sz, sz, 0, dx, dy + sz);
        } catch (DocumentException ex) {
            Log.error(ex.getMessage());
        }
    }
View Full Code Here

            PdfWriter writer = PdfWriter.getInstance(document, tmp);
            writer.setFullCompression();
            // step 3: we open the document
            document.open();
            // step 4: adding the content
            PdfContentByte cb = writer.getDirectContent();
            PdfImportedPage page;
            float offsetX;
            for (int p = 1; p <= total; p++) {
                offsetX = 0;
                if (p % 2 != 0) {
                    document.newPage();
                } else {
                    offsetX = pageSize.getWidth();
                }
                page = writer.getImportedPage(reader, p);
                cb.addTemplate(page, offsetX, 0);
            }
            // step 5: we close the document
            document.close();

            PdfReader reader2 = new PdfReader(new ByteArrayInputStream(tmp.toByteArray()));
View Full Code Here

   * @throws BadElementException
   *             on error
   * @throws IOException
   */
  public static Image getInstance(final PdfWriter writer, final java.awt.Image awtImage, final float quality) throws BadElementException, IOException {
    return getInstance(new PdfContentByte(writer), awtImage, quality);
  }
View Full Code Here

   * @throws BadElementException
   *             on error
   * @throws IOException
   */
  public static Image getInstance(final PdfWriter writer, final java.awt.Image awtImage, final float quality) throws BadElementException, IOException {
    return getInstance(new PdfContentByte(writer), awtImage, quality);
  }
View Full Code Here

   * @throws BadElementException
   *             on error
   * @throws IOException
   */
  public static Image getInstance(PdfWriter writer, java.awt.Image awtImage, float quality) throws BadElementException, IOException {
    return getInstance(new PdfContentByte(writer), awtImage, quality);
  }
View Full Code Here

TOP

Related Classes of com.itextpdf.text.pdf.PdfContentByte$UncoloredPattern

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.