Example usage for com.itextpdf.text.pdf PdfWriter setDefaultColorspace

List of usage examples for com.itextpdf.text.pdf PdfWriter setDefaultColorspace

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf PdfWriter setDefaultColorspace.

Prototype

public void setDefaultColorspace(final PdfName key, final PdfObject cs) 

Source Link

Document

Use this method to sets the default colorspace that will be applied to all the document.

Usage

From source file:shared.SVGtoPDF.java

License:Open Source License

/**
 * Creates a PDF document./*w  w  w. j a  va 2  s. c o  m*/
 * @param path 
 * @param filename the path to the new PDF document
 * @throws DocumentException 
 * @throws IOException
 * @throws SQLException 
 */
public void createPdf(String svgDocument, Point size, String path) throws IOException, DocumentException {
    svgDocument = convertSVG(svgDocument);
    Document document = new Document(new Rectangle(size.x, size.y));
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(path));
    //writer.setRgbTransparencyBlending(false);
    writer.setDefaultColorspace(PdfName.DEFAULTCMYK, PdfName.DEFAULTCMYK);
    document.open();
    PdfContentByte cb = writer.getDirectContent();
    PdfTemplate template = cb.createTemplate(size.x, size.y);
    drawSvg(svgDocument, template, size);
    cb.addTemplate(template, 0, 0);
    // step 5
    document.close();
}