Example usage for com.lowagie.text.pdf CMYKColor CMYKColor

List of usage examples for com.lowagie.text.pdf CMYKColor CMYKColor

Introduction

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

Prototype

public CMYKColor(float floatCyan, float floatMagenta, float floatYellow, float floatBlack) 

Source Link

Document

Construct a CMYK Color.

Usage

From source file:org.xhtmlrenderer.pdf.ITextOutputDevice.java

License:Open Source License

public void setColor(FSColor color) {
    if (color instanceof FSRGBColor) {
        FSRGBColor rgb = (FSRGBColor) color;
        _color = new Color(rgb.getRed(), rgb.getGreen(), rgb.getBlue());
    } else if (color instanceof FSCMYKColor) {
        FSCMYKColor cmyk = (FSCMYKColor) color;
        _color = new CMYKColor(cmyk.getCyan(), cmyk.getMagenta(), cmyk.getYellow(), cmyk.getBlack());
    } else {//w  ww.  j  a v a  2  s  . c  o m
        throw new RuntimeException("internal error: unsupported color class " + color.getClass().getName());
    }
}

From source file:questions.importpages.NameCard.java

public static void createOneCard() throws DocumentException, IOException {
    Rectangle rect = new Rectangle(Utilities.millimetersToPoints(86.5f), Utilities.millimetersToPoints(55));
    Document document = new Document(rect);
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(CARD));
    writer.setViewerPreferences(PdfWriter.PrintScalingNone);
    document.open();/*www .  j  a  v a2s .  co m*/
    PdfReader reader = new PdfReader(LOGO);
    Image img = Image.getInstance(writer.getImportedPage(reader, 1));
    img.scaleToFit(rect.getWidth() / 1.5f, rect.getHeight() / 1.5f);
    img.setAbsolutePosition((rect.getWidth() - img.getScaledWidth()) / 2,
            (rect.getHeight() - img.getScaledHeight()) / 2);
    document.add(img);
    document.newPage();
    BaseFont bf = BaseFont.createFont(FONT, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
    Font font = new Font(bf, 12);
    font.setColor(new CMYKColor(1, 0.5f, 0, 0.467f));
    ColumnText column = new ColumnText(writer.getDirectContent());
    Paragraph p;
    p = new Paragraph("Bruno Lowagie\n1T3XT\nbruno@1t3xt.com", font);
    p.setAlignment(Element.ALIGN_CENTER);
    column.addElement(p);
    column.setSimpleColumn(0, 0, rect.getWidth(), rect.getHeight() * 0.75f);
    column.go();
    document.close();
}