01: /*
02: *
03: * The contents of this file are subject to the Mozilla Public License Version 1.1
04: * (the "License"); you may not use this file except in compliance with the License.
05: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
06: *
07: * Software distributed under the License is distributed on an "AS IS" basis,
08: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
09: * for the specific language governing rights and limitations under the License.
10: *
11: * The Original Code is 'iText, a free JAVA-PDF library'.
12: *
13: * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
14: * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
15: * All Rights Reserved.
16: * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
17: * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
18: *
19: * Contributor(s): all the names of the contributors are added in the source code
20: * where applicable.
21: *
22: * Alternatively, the contents of this file may be used under the terms of the
23: * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
24: * provisions of LGPL are applicable instead of those above. If you wish to
25: * allow use of your version of this file only under the terms of the LGPL
26: * License and not to allow others to use your version of this file under
27: * the MPL, indicate your decision by deleting the provisions above and
28: * replace them with the notice and other provisions required by the LGPL.
29: * If you do not delete the provisions above, a recipient may use your version
30: * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
31: *
32: * This library is free software; you can redistribute it and/or modify it
33: * under the terms of the MPL as stated above or under the terms of the GNU
34: * Library General Public License as published by the Free Software Foundation;
35: * either version 2 of the License, or any later version.
36: *
37: * This library is distributed in the hope that it will be useful, but WITHOUT
38: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
39: * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
40: * details.
41: *
42: * If you didn't download this code from the following link, you should check if
43: * you aren't using an obsolete version:
44: * http://www.lowagie.com/iText/
45: */
46: package com.lowagie.text.pdf;
47:
48: import java.awt.color.ICC_Profile;
49:
50: import com.lowagie.text.ExceptionConverter;
51:
52: /**
53: * A <CODE>PdfICCBased</CODE> defines a ColorSpace
54: *
55: * @see PdfStream
56: */
57:
58: public class PdfICCBased extends PdfStream {
59:
60: public PdfICCBased(ICC_Profile profile) {
61: super ();
62: try {
63: int numberOfComponents = profile.getNumComponents();
64: switch (numberOfComponents) {
65: case 1:
66: put(PdfName.ALTERNATE, PdfName.DEVICEGRAY);
67: break;
68: case 3:
69: put(PdfName.ALTERNATE, PdfName.DEVICERGB);
70: break;
71: case 4:
72: put(PdfName.ALTERNATE, PdfName.DEVICECMYK);
73: break;
74: default:
75: throw new PdfException(numberOfComponents
76: + " component(s) is not supported in PDF1.4");
77: }
78: put(PdfName.N, new PdfNumber(numberOfComponents));
79: bytes = profile.getData();
80: flateCompress();
81: } catch (Exception e) {
82: throw new ExceptionConverter(e);
83: }
84: }
85: }
|