Example usage for com.lowagie.text Rectangle Rectangle

List of usage examples for com.lowagie.text Rectangle Rectangle

Introduction

In this page you can find the example usage for com.lowagie.text Rectangle Rectangle.

Prototype

public Rectangle(Rectangle rect) 

Source Link

Document

Constructs a Rectangle -object.

Usage

From source file:ExamplePdfPrinter.java

License:Open Source License

public static void main(String[] args) throws Exception {
    SpooledFile spooledFile = null; // TODO: provide your spool file!
    final IScsDataProvider dp = As400ScsDataProviderFactory.getPrintObjectDataProvider(spooledFile);
    final ReaderConfig rcfg = ReaderConfig.getDefault();
    final SCSStreamReader reader = new SCSStreamReader(dp, rcfg);

    PrinterConfig pcfg = PrinterConfig.getDefault();
    float FONT_SIZE = 9.0F;
    float leading = FONT_SIZE * 1.05F;

    // calculate font, font size, and margins for the PDF
    final Font monoSpacedFont = FontFactory.getFont(BaseFont.COURIER, FONT_SIZE);
    final Font monoSpacedFontBold = FontFactory.getFont(BaseFont.COURIER_BOLD, Font.BOLD);
    Rectangle pageSize = new Rectangle(PageSize.A4);
    final Document pdfdoc = new Document(pageSize);

    final FileOutputStream fos = new FileOutputStream("test.pdf");
    final PdfWriter pdfwriter = PdfWriter.getInstance(pdfdoc, fos);
    pdfdoc.open();// ww w .  j  a v  a  2s.co  m

    PdfPrinter pdfprinter = new PdfPrinter(pcfg, pdfdoc, monoSpacedFont, monoSpacedFontBold, leading);

    try {
        while (reader.hasNext()) {
            final IPrinterMicroCommand event = reader.next();
            if (event == null)
                break;
            pdfprinter.runMicroCommand(event);
        }
    } catch (EndOfFileSignal e) {
        System.out.println("eof.");
    }

    pdfprinter.finish();
    pdfdoc.close();
    pdfwriter.close();
}

From source file:com.estate.pdf.Page.java

protected Rectangle adjustPlacement(Rectangle rctIn) {
    Rectangle rctOut = new Rectangle(rctIn);

    rctOut.setLeft(rctOut.getLeft() - _1_4TH);
    rctOut.setBottom(rctOut.getBottom() - _1_4TH);
    return rctOut;
}

From source file:com.estate.pdf.Page.java

protected Rectangle calcSectionRect(Rectangle rct, String heading, String lines[], int bullet) {
    Rectangle r;/*from ww w  .j  ava2  s. c o m*/
    Rectangle secRect = new Rectangle(rct);
    PageSection psc = new PageSection(writer);
    r = psc.calcSectionRect(secRect, heading, lines, bullet);
    return r;
}

From source file:com.estate.pdf.Page.java

protected Rectangle calcSectionRect(Rectangle rct, String heading, String lines[], int bullet,
        float headingSize, float textSize) {
    Rectangle r;//from  www .  j ava2 s .  com
    Rectangle secRect = new Rectangle(rct);
    PageSection psc = new PageSection(writer);
    float hs = psc.getHeadingSize();
    float ts = psc.getTextSize();

    psc.setHeadingSize(headingSize);
    psc.setTextSize(textSize);
    r = psc.calcSectionRect(secRect, heading, lines, bullet);
    psc.setHeadingSize(hs);
    psc.setTextSize(ts);

    return r;

}

From source file:com.estate.pdf.Page.java

protected void drawDiagram(Image img, Rectangle rct, int align, int DPI) {
    Rectangle diagRect = new Rectangle(rct);
    Diagram d = new Diagram(img);
    d.placeDiagram(diagRect, document, align, DPI);

}

From source file:com.estate.pdf.Page.java

protected void drawDiagram(String name, Rectangle rct, int align) {
    Rectangle diagRect = new Rectangle(rct);
    Diagram d = new Diagram(name);
    d.placeDiagram(diagRect, document, align);

}

From source file:com.estate.pdf.Page.java

protected void drawDiagram(String name, Rectangle rct, int align, int DPI) {
    Rectangle diagRect = new Rectangle(rct);
    Diagram d = new Diagram(name);
    d.placeDiagram(diagRect, document, align, DPI);

}

From source file:com.estate.pdf.Page.java

protected void drawHeader(String header, String title) {
    PageHeader pgh = new PageHeader(writer);
    Rectangle rct = new Rectangle(document.getPageSize());
    pgh.writeHeader(rct, header, title);

}

From source file:com.estate.pdf.Page.java

protected Rectangle drawLabel(String text, Rectangle rct, String fontName, Color color, float ptSize, int align,
        int anchor) {
    Rectangle lblRect = new Rectangle(rct);
    Label lbl = new Label(writer);
    BaseFont font = PageUtils.LoadFont(fontName);
    lblRect = lbl.displayLabel(lblRect, text, font, ptSize, color, align, anchor);
    return (lblRect);
}

From source file:com.estate.pdf.Page.java

protected Rectangle drawSection(Rectangle rct, String heading, String lines[], int bullet) {
    Rectangle r;//from   w  w w.  j a v  a 2s  . c  om
    Rectangle secRect = new Rectangle(rct);
    PageSection psc = new PageSection(writer);
    r = psc.displaySection(secRect, heading, lines, bullet);
    return r;
}