Search in sources :

Example 1 with DottedBorder

use of com.itextpdf.layout.borders.DottedBorder in project i7js-highlevel by itext.

the class C05E06_CellBorders1 method createPdf.

public void createPdf(String dest) throws IOException {
    // Initialize PDF document
    PdfDocument pdf = new PdfDocument(new PdfWriter(dest));
    // Initialize document
    Document document = new Document(pdf);
    Table table = new Table(UnitValue.createPercentArray(new float[] { 2, 1, 1 }));
    table.setWidth(UnitValue.createPercentValue(80)).setHorizontalAlignment(HorizontalAlignment.CENTER).setTextAlignment(TextAlignment.CENTER);
    table.addCell(new Cell(1, 3).add(new Paragraph("Cell with colspan 3")).setVerticalAlignment(VerticalAlignment.MIDDLE).setBorder(new DashedBorder(0.5f)));
    table.addCell(new Cell(2, 1).add(new Paragraph("Cell with rowspan 2")).setVerticalAlignment(VerticalAlignment.MIDDLE).setBorderBottom(new DottedBorder(0.5f)).setBorderLeft(new DottedBorder(0.5f)));
    table.addCell(new Cell().add(new Paragraph("row 1; cell 1")).setBorder(new DottedBorder(ColorConstants.ORANGE, 0.5f)));
    table.addCell(new Cell().add(new Paragraph("row 1; cell 2")));
    table.addCell(new Cell().add(new Paragraph("row 2; cell 1")).setBorderBottom(new SolidBorder(2)));
    table.addCell(new Cell().add(new Paragraph("row 2; cell 2")).setBorderBottom(new SolidBorder(2)));
    document.add(table);
    document.close();
}
Also used : Table(com.itextpdf.layout.element.Table) PdfWriter(com.itextpdf.kernel.pdf.PdfWriter) DashedBorder(com.itextpdf.layout.borders.DashedBorder) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) Document(com.itextpdf.layout.Document) DottedBorder(com.itextpdf.layout.borders.DottedBorder) Cell(com.itextpdf.layout.element.Cell) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) Paragraph(com.itextpdf.layout.element.Paragraph) SolidBorder(com.itextpdf.layout.borders.SolidBorder)

Example 2 with DottedBorder

use of com.itextpdf.layout.borders.DottedBorder in project MtgDesktopCompanion by nicho92.

the class PDFExport method createCell.

private Cell createCell(MagicCard card) throws IOException {
    ImageData imageData = null;
    try {
        imageData = ImageDataFactory.create(getEnabledPlugin(MTGPictureProvider.class).getFullSizePicture(card), null);
    } catch (Exception e) {
        imageData = ImageDataFactory.create(getEnabledPlugin(MTGPictureProvider.class).getBackPicture(), null);
    }
    var image = new Image(imageData);
    image.scaleAbsolute(2.49f * userPoint, 3.48f * userPoint);
    var cell = new Cell();
    if (getBoolean("PRINT_CUT_LINE")) {
        cell.setBorder(new DottedBorder(0.5f));
    } else
        cell.setBorder(Border.NO_BORDER);
    if (getInt(SPACE) != null)
        cell.setPadding(getInt(SPACE));
    cell.add(image);
    return cell;
}
Also used : MTGPictureProvider(org.magic.api.interfaces.MTGPictureProvider) ImageData(com.itextpdf.io.image.ImageData) Image(com.itextpdf.layout.element.Image) DottedBorder(com.itextpdf.layout.borders.DottedBorder) Cell(com.itextpdf.layout.element.Cell) NotImplementedException(org.apache.commons.lang3.NotImplementedException) IOException(java.io.IOException)

Example 3 with DottedBorder

use of com.itextpdf.layout.borders.DottedBorder in project i7js-highlevel by itext.

the class CellProperties method createPdf.

public void createPdf(String dest) throws IOException {
    // Initialize PDF document
    PdfDocument pdf = new PdfDocument(new PdfWriter(dest));
    // Initialize document
    Document document = new Document(pdf);
    Table table = new Table(UnitValue.createPercentArray(2)).useAllAvailableWidth();
    PdfFont font = PdfFontFactory.createFont(StandardFonts.TIMES_ROMAN);
    table.addCell(new Cell().add(new Paragraph("Test 1")).setHeight(50).setDestination("Top"));
    Style style = new Style();
    style.setBackgroundColor(ColorConstants.YELLOW);
    table.addCell(new Cell().setBorder(new DottedBorder(5)).add(new Paragraph("Test 2")).addStyle(style).setRelativePosition(10, 10, 50, 10));
    table.addCell(new Cell().add(new Paragraph("Test 3")).setVerticalAlignment(VerticalAlignment.BOTTOM));
    table.addCell(new Cell().add(ParagraphProperties.getNewParagraphInstance()).setHyphenation(new HyphenationConfig("en", "uk", 3, 3)));
    table.addCell(new Cell().add(new Paragraph("Rotated")).setRotationAngle(Math.PI / 18).setFont(font).setFontSize(8).setFontColor(ColorConstants.RED));
    table.addCell(new Cell().add(new Paragraph("Centered")).setTextAlignment(TextAlignment.CENTER).setAction(PdfAction.createGoTo("Top")));
    table.addCell(new Cell().add(new Paragraph("Test 5")).setBackgroundColor(ColorConstants.BLUE));
    table.addCell(new Cell().add(ParagraphProperties.getNewParagraphInstance()).setBackgroundColor(ColorConstants.RED).setPaddingLeft(20).setPaddingRight(50));
    table.addCell(new Cell().add(new Paragraph("Test 7")).setBackgroundColor(ColorConstants.RED));
    table.addCell(new Cell().add(new Paragraph("Test 8")).setBackgroundColor(ColorConstants.BLUE).setMarginBottom(10));
    table.addCell(new Cell().add(new Paragraph("Test 9")).setBackgroundColor(ColorConstants.BLUE));
    table.addCell(new Cell().add(new Paragraph("Test 10")).setBackgroundColor(ColorConstants.RED));
    table.addCell(new Cell().add(ParagraphProperties.getNewParagraphInstance()).setBackgroundColor(ColorConstants.RED).setMargin(50).setPadding(30));
    table.addCell(new Cell().add(new Paragraph("Test 12")).setBackgroundColor(ColorConstants.BLUE));
    document.add(table);
    SolidBorder border = new SolidBorder(ColorConstants.RED, 2);
    Cell cell = new Cell().add(new Paragraph("Test")).setFixedPosition(100, 400, 350).setBorder(border).setBackgroundColor(ColorConstants.BLUE).setHeight(100).setHorizontalAlignment(HorizontalAlignment.CENTER);
    document.add(cell);
    document.close();
}
Also used : Table(com.itextpdf.layout.element.Table) PdfWriter(com.itextpdf.kernel.pdf.PdfWriter) PdfFont(com.itextpdf.kernel.font.PdfFont) Style(com.itextpdf.layout.Style) HyphenationConfig(com.itextpdf.layout.hyphenation.HyphenationConfig) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) Document(com.itextpdf.layout.Document) DottedBorder(com.itextpdf.layout.borders.DottedBorder) Cell(com.itextpdf.layout.element.Cell) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) Paragraph(com.itextpdf.layout.element.Paragraph) SolidBorder(com.itextpdf.layout.borders.SolidBorder)

Example 4 with DottedBorder

use of com.itextpdf.layout.borders.DottedBorder in project i7js-highlevel by itext.

the class TableProperties method createPdf.

public void createPdf(String dest) throws IOException {
    // Initialize PDF document
    PdfDocument pdf = new PdfDocument(new PdfWriter(dest));
    // Initialize document
    Document document = new Document(pdf);
    PdfFont font = PdfFontFactory.createFont(StandardFonts.TIMES_ROMAN);
    Style style = new Style();
    style.setBackgroundColor(ColorConstants.YELLOW);
    document.add(createNewTable().addStyle(style).setDestination("Top").setWidth(300).setHorizontalAlignment(HorizontalAlignment.CENTER)).setHorizontalAlignment(HorizontalAlignment.CENTER);
    document.add(createNewTable().setBorder(new DottedBorder(5)).setHyphenation(new HyphenationConfig("en", "uk", 3, 3)));
    document.add(createNewTable().setTextAlignment(TextAlignment.CENTER));
    document.add(ListSeparatorProperties.createNewSeparator().setMargin(10).setWidth(300).setKeepWithNext(true));
    document.add(createNewTable().setKeepTogether(true).setWidth(UnitValue.createPercentValue(90)));
    document.add(createNewTable());
    document.add(createNewTable().setRelativePosition(10, 10, 50, 10));
    document.add(createNewTable());
    document.add(new AreaBreak());
    document.add(createNewTable().setFixedPosition(100, 400, 350).setAction(PdfAction.createGoTo("Top")));
    document.add(new AreaBreak());
    document.add(createNewTable().setBackgroundColor(ColorConstants.YELLOW).setMarginBottom(10));
    document.add(createNewTable().setBackgroundColor(ColorConstants.LIGHT_GRAY).setPaddingLeft(20).setPaddingRight(50));
    document.add(createNewTable().setBackgroundColor(ColorConstants.YELLOW));
    document.add(createNewTable().setBackgroundColor(ColorConstants.LIGHT_GRAY));
    document.add(createNewTable().setBackgroundColor(ColorConstants.YELLOW));
    document.add(createNewTable().setBackgroundColor(ColorConstants.LIGHT_GRAY).setMargin(50).setPadding(30));
    document.add(createNewTable().setBackgroundColor(ColorConstants.YELLOW));
    document.add(createNewTable().setBackgroundColor(ColorConstants.LIGHT_GRAY));
    document.close();
}
Also used : PdfWriter(com.itextpdf.kernel.pdf.PdfWriter) PdfFont(com.itextpdf.kernel.font.PdfFont) Style(com.itextpdf.layout.Style) HyphenationConfig(com.itextpdf.layout.hyphenation.HyphenationConfig) AreaBreak(com.itextpdf.layout.element.AreaBreak) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) Document(com.itextpdf.layout.Document) DottedBorder(com.itextpdf.layout.borders.DottedBorder) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument)

Aggregations

DottedBorder (com.itextpdf.layout.borders.DottedBorder)4 PdfDocument (com.itextpdf.kernel.pdf.PdfDocument)3 PdfWriter (com.itextpdf.kernel.pdf.PdfWriter)3 Document (com.itextpdf.layout.Document)3 Cell (com.itextpdf.layout.element.Cell)3 PdfFont (com.itextpdf.kernel.font.PdfFont)2 Style (com.itextpdf.layout.Style)2 SolidBorder (com.itextpdf.layout.borders.SolidBorder)2 Paragraph (com.itextpdf.layout.element.Paragraph)2 Table (com.itextpdf.layout.element.Table)2 HyphenationConfig (com.itextpdf.layout.hyphenation.HyphenationConfig)2 ImageData (com.itextpdf.io.image.ImageData)1 DashedBorder (com.itextpdf.layout.borders.DashedBorder)1 AreaBreak (com.itextpdf.layout.element.AreaBreak)1 Image (com.itextpdf.layout.element.Image)1 IOException (java.io.IOException)1 NotImplementedException (org.apache.commons.lang3.NotImplementedException)1 MTGPictureProvider (org.magic.api.interfaces.MTGPictureProvider)1