Example #1
0
 public static ICC_Profile GetInstance(byte[] data)
 {
     if (data.Length < 128 | data[36] != 0x61 || data[37] != 0x63
         || data[38] != 0x73 || data[39] != 0x70)
         throw new ArgumentException("Invalid ICC profile");
     ICC_Profile icc = new ICC_Profile();
     icc.data = data;
     object cs = cstags[Encoding.ASCII.GetString(data, 16, 4)];
     icc.numComponents = (cs == null ? 0 : (int)cs);
     return icc;
 }
Example #2
0
 /**
 * Creates an ICC stream.
 *
 * @param   compressionLevel    the compressionLevel
 *
 * @param   profile an ICC profile
 * @since   2.1.3   (replacing the constructor without param compressionLevel)
 */
 public PdfICCBased(ICC_Profile profile, int compressionLevel)
 {
     int numberOfComponents = profile.NumComponents;
     switch (numberOfComponents) {
         case 1:
             Put(PdfName.ALTERNATE, PdfName.DEVICEGRAY);
             break;
         case 3:
             Put(PdfName.ALTERNATE, PdfName.DEVICERGB);
             break;
         case 4:
             Put(PdfName.ALTERNATE, PdfName.DEVICECMYK);
             break;
         default:
             throw new PdfException(numberOfComponents + " Component(s) is not supported in iText");
     }
     Put(PdfName.N, new PdfNumber(numberOfComponents));
     bytes = profile.Data;
     FlateCompress(compressionLevel);
 }
Example #3
0
 /// <summary>
 /// Constructs an Image object duplicate.
 /// </summary>
 /// <param name="image">another Image object.</param>
 public Image(Image image)
     : base(image)
 {
     this.type = image.type;
     this.url = image.url;
     this.alignment = image.alignment;
     this.alt = image.alt;
     this.absoluteX = image.absoluteX;
     this.absoluteY = image.absoluteY;
     this.plainWidth = image.plainWidth;
     this.plainHeight = image.plainHeight;
     this.scaledWidth = image.scaledWidth;
     this.scaledHeight = image.scaledHeight;
     this.rotationRadians = image.rotationRadians;
     this.indentationLeft = image.indentationLeft;
     this.indentationRight = image.indentationRight;
     this.colorspace = image.colorspace;
     this.rawData = image.rawData;
     this.template = image.template;
     this.bpc = image.bpc;
     this.transparency = image.transparency;
     this.mySerialId = image.mySerialId;
     this.invert = image.invert;
     this.dpiX = image.dpiX;
     this.dpiY = image.dpiY;
     this.mask = image.mask;
     this.imageMask = image.imageMask;
     this.interpolation = image.interpolation;
     this.annotation = image.annotation;
     this.profile = image.profile;
     this.deflated = image.deflated;
     this.additional = image.additional;
     this.smask = image.smask;
     this.XYRatio = image.XYRatio;
     this.originalData = image.originalData;
     this.originalType = image.originalType;
     this.spacingAfter = image.spacingAfter;
     this.spacingBefore = image.spacingBefore;
     this.widthPercentage = image.widthPercentage;
     this.layer = image.layer;
     this.initialRotation = image.initialRotation;
     this.directReference = image.directReference;
 }
Example #4
0
        //  [C11] Output intents
        /**
        * Sets the values of the output intent dictionary. Null values are allowed to
        * suppress any key.
        * @param outputConditionIdentifier a value
        * @param outputCondition a value
        * @param registryName a value
        * @param info a value
        * @param destOutputProfile a value
        * @throws IOException on error
        */
        public void SetOutputIntents(String outputConditionIdentifier, String outputCondition, String registryName, String info, ICC_Profile colorProfile)
        {
            PdfDictionary outa = ExtraCatalog; //force the creation
            outa = new PdfDictionary(PdfName.OUTPUTINTENT);
            if (outputCondition != null)
                outa.Put(PdfName.OUTPUTCONDITION, new PdfString(outputCondition, PdfObject.TEXT_UNICODE));
            if (outputConditionIdentifier != null)
                outa.Put(PdfName.OUTPUTCONDITIONIDENTIFIER, new PdfString(outputConditionIdentifier, PdfObject.TEXT_UNICODE));
            if (registryName != null)
                outa.Put(PdfName.REGISTRYNAME, new PdfString(registryName, PdfObject.TEXT_UNICODE));
            if (info != null)
                outa.Put(PdfName.INFO, new PdfString(info, PdfObject.TEXT_UNICODE));
            if (colorProfile != null) {
                PdfStream stream = new PdfICCBased(colorProfile, compressionLevel);
                outa.Put(PdfName.DESTOUTPUTPROFILE, AddToBody(stream).IndirectReference);
            }

            PdfName intentSubtype;
            if (pdfxConformance.IsPdfA1() || "PDFA/1".Equals(outputCondition)) {
                intentSubtype = PdfName.GTS_PDFA1;
            }
            else {
                intentSubtype = PdfName.GTS_PDFX;
            }

            outa.Put(PdfName.S, intentSubtype);

            extraCatalog.Put(PdfName.OUTPUTINTENTS, new PdfArray(outa));
        }
Example #5
0
 /**
  * Creates an ICC stream.
  * @param   profile an ICC profile
  */
 public PdfICCBased(ICC_Profile profile) : this(profile, DEFAULT_COMPRESSION)
 {
     ;
 }
Example #6
0
 /**
 * Creates an ICC stream.
 * @param   profile an ICC profile
 */
 public PdfICCBased(ICC_Profile profile)
     : this(profile, DEFAULT_COMPRESSION)
 {
     ;
 }