Example usage for com.itextpdf.text Rectangle setBorderColor

List of usage examples for com.itextpdf.text Rectangle setBorderColor

Introduction

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

Prototype

public void setBorderColor(final BaseColor borderColor) 

Source Link

Document

Sets the color of the border.

Usage

From source file:com.vectorprint.report.itext.style.stylers.Border.java

License:Open Source License

@Override
public <E> E style(E text, Object data) throws VectorPrintException {
    Rectangle cell = (Rectangle) text;

    cell.setBorderWidth(getValue(BORDERWIDTH, Float.class));
    cell.setBorder(getValue(TOPRIGTHBOTTOMLEFT_PARAM, POSITION.class).getPosition());

    if (getValue(COLOR_PARAM, Color.class) != null) {
        cell.setBorderColor(itextHelper.fromColor(getValue(COLOR_PARAM, Color.class)));
    }/*from www. j  av a2  s  . com*/

    return text;
}

From source file:GUI_Apoteker.Panel_Detil_PO.java

private void createPdf(List<detil_pesan_obat> a) {
    try {/*from   www  . j av a  2 s . c o m*/
        JFileChooser saveFile = new JFileChooser();
        String namaFile = "D:/kampus/si-klinik-PO" + po.getId_Pemesanan_obat() + ".pdf";
        saveFile.setSelectedFile(new File(namaFile));
        String result = null;
        if (saveFile.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) {
            result = saveFile.getSelectedFile().toString();
        } else {
            System.out.println("No Selection ");
        }

        // TODO add your handling code here:
        Document document = new Document();

        PdfWriter writer = null;
        try {
            writer = PdfWriter.getInstance(document, new FileOutputStream(result));
        } catch (FileNotFoundException ex) {
            Logger.getLogger(Panel_Detil_PO.class.getName()).log(Level.SEVERE, null, ex);
        }
        document.open();
        PdfContentByte canvas = writer.getDirectContent();
        Rectangle rect = new Rectangle(50, 800, 550, 700);
        rect.setBorder(Rectangle.BOX);
        rect.setBorderWidth(5);
        rect.setBorderColor(BaseColor.BLACK);
        canvas.rectangle(rect);
        Paragraph preface;
        preface = getPreface("Bulanan");
        document.add(preface);
        document.add(Chunk.NEWLINE);
        document.add(Chunk.NEWLINE);
        document.add(createTableBulanan(a));
        document.close();
        open(result);
    } catch (DocumentException ex) {
        Logger.getLogger(Panel_Detil_PO.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:GUI_StafKlinik.Panel_Laporan_Keuangan.java

private void createPdf(List<Laporan_Keuangan> list) {
    JFileChooser saveFile = new JFileChooser();
    saveFile.setSelectedFile(new File("D:/document/Laporan Keuangan.pdf"));
    String result = null;//from   ww  w  . j  ava 2 s. c  om
    if (saveFile.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) {
        result = saveFile.getSelectedFile().toString();
    } else {
        System.out.println("No Selection ");
    }
    try {
        // TODO add your handling code here:
        Document document = new Document();
        try {
            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(result));
            document.open();
            PdfContentByte canvas = writer.getDirectContent();
            Rectangle rect = new Rectangle(50, 800, 550, 700);
            rect.setBorder(Rectangle.BOX);
            rect.setBorderWidth(0);
            rect.setBorderColor(BaseColor.BLACK);
            canvas.rectangle(rect);
            Paragraph preface;
            preface = getPreface("Laporan Keuangan");
            document.add(preface);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(createTableLaporan(list));
            document.close();
            open(result);
        } catch (DocumentException ex) {
            Logger.getLogger(Panel_Laporan_Keuangan.class.getName()).log(Level.SEVERE, null, ex);
        }
    } catch (FileNotFoundException ex) {
        Logger.getLogger(Panel_Laporan_Keuangan.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:GUI_StafKlinik.Panel_Penggajian.java

private void createPdf(List<Penggajian> list) {
    JFileChooser saveFile = new JFileChooser();
    saveFile.setSelectedFile(new File("D:/document/Slip Gaji.pdf"));
    String result = null;/*from  ww w  .  j  av  a 2s  .  co  m*/
    if (saveFile.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) {
        result = saveFile.getSelectedFile().toString();
    } else {
        System.out.println("No Selection ");
    }
    try {
        Document document = new Document();
        try {
            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(result));
            document.open();
            PdfContentByte canvas = writer.getDirectContent();

            for (int i = 0; i < list.size(); i++) {
                document.newPage();
                Rectangle rect = new Rectangle(50, 800, 550, 700);
                rect.setBorder(Rectangle.BOX);
                rect.setBorderWidth(0);
                rect.setBorderColor(BaseColor.BLACK);
                canvas.rectangle(rect);
                Paragraph preface;
                preface = getPreface("Slip Gaji");
                document.add(preface);
                document.add(Chunk.NEWLINE);
                document.add(Chunk.NEWLINE);
                document.add(createTableLaporan(list.get(i)));
            }
            document.close();
            open(result);
        } catch (DocumentException ex) {
            Logger.getLogger(Panel_Laporan_Keuangan.class.getName()).log(Level.SEVERE, null, ex);
        }
    } catch (FileNotFoundException ex) {
        Logger.getLogger(Panel_Laporan_Keuangan.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:info.longnetpro.examples.PdfLibExamples.java

public static void generatePdf()
        throws DocumentException, URISyntaxException, MalformedURLException, IOException {
    String licFile = getLicenseFilePath();
    loadLicenseFile(licFile);//from  w ww . j a  v a 2 s  .  c o m

    String dest = getTargetFilePath();
    Document doc = new Document();
    PdfWriter.getInstance(doc, new FileOutputStream(dest));
    Rectangle pageSize = PageSize.LETTER;
    Rectangle rect = new Rectangle(0f, 0f, 50f, 100f);
    rect.setBorder(15);
    rect.setBorderColor(BaseColor.RED);
    rect.setBorderWidth(.5f);
    rect.setBackgroundColor(BaseColor.BLUE);
    doc.setPageSize(pageSize);
    doc.open();

    Page page = new Page(pageSize.getWidth(), pageSize.getHeight());
    ContentBox rpage = page.margin(new Float[] { 10f, 50f, 10f, 50f });

    for (Anchor anchor : Anchor.values()) {
        ContentBox box = new ContentBox(50f, 100f);
        float offx = anchor.equals(Anchor.CENTER) ? -50f : 0f;
        float offy = anchor.equals(Anchor.CENTER) ? -50f : 0f;

        ContentBox rr = anchor.anchorElement(rpage, box, offx, offy);

        if (anchor.equals(Anchor.BOTTOM_LEFT)) {
            float[] dim = box.scaleByPercentage(0.5f);
            //rr = rr.reposition(dim[0], dim[1], Anchor.TOP_RIGHT);
        }

        rect.setLeft(rr.getLeft());
        rect.setBottom(rr.getBottom());
        rect.setRight(rr.getRight());
        rect.setTop(rr.getTop());
        doc.add(rect);
    }
    String imageFile = getImageFilePath();
    Image image = Image.getInstance(imageFile);

    float width = Measurement.dotsToUserUnits(image.getWidth(), 1200);
    float height = Measurement.dotsToUserUnits(image.getHeight(), 1200);

    System.out.println(width + " " + height);

    ContentBox img = Anchor.BOTTOM_LEFT.anchorElement(rpage, width, height);

    image.scaleToFit(width, height);
    image.setAbsolutePosition(img.getLeft(), img.getBottom());

    System.out.println(image.getWidth() + " " + image.getHeight());
    System.out.println(image.getAbsoluteX() + " " + image.getAbsoluteY());

    doc.add(image);
    doc.close();
}