iTextSharp.text.pdf.PdfWriter.IsPdfX C# (CSharp) Méthode

IsPdfX() public méthode

public IsPdfX ( ) : bool
Résultat bool
        public bool IsPdfX()
        {
            if (pdfIsoConformance is PdfXConformanceImp)
                return ((IPdfXConformance)pdfIsoConformance).IsPdfX();
            else
                return false;
        }

Usage Example

 /**
 * Business logic that checks if a certain object is in conformance with PDF/X.
 * @param writer    the writer that is supposed to write the PDF/X file
 * @param key       the type of PDF/X conformance that has to be checked
 * @param obj1      the object that is checked for conformance
 */
 public static void CheckPDFXConformance(PdfWriter writer, int key, Object obj1)
 {
     if (writer == null || !writer.IsPdfX())
         return;
     int conf = writer.PDFXConformance;
     switch (key) {
         case PDFXKEY_COLOR:
             switch (conf) {
                 case PdfWriter.PDFX1A2001:
                     if (obj1 is ExtendedColor) {
                         ExtendedColor ec = (ExtendedColor)obj1;
                         switch (ec.Type) {
                             case ExtendedColor.TYPE_CMYK:
                             case ExtendedColor.TYPE_GRAY:
                                 return;
                             case ExtendedColor.TYPE_RGB:
                                 throw new PdfXConformanceException("Colorspace RGB is not allowed.");
                             case ExtendedColor.TYPE_SEPARATION:
                                 SpotColor sc = (SpotColor)ec;
                                 CheckPDFXConformance(writer, PDFXKEY_COLOR, sc.PdfSpotColor.AlternativeCS);
                                 break;
                             case ExtendedColor.TYPE_SHADING:
                                 ShadingColor xc = (ShadingColor)ec;
                                 CheckPDFXConformance(writer, PDFXKEY_COLOR, xc.PdfShadingPattern.Shading.ColorSpace);
                                 break;
                             case ExtendedColor.TYPE_PATTERN:
                                 PatternColor pc = (PatternColor)ec;
                                 CheckPDFXConformance(writer, PDFXKEY_COLOR, pc.Painter.DefaultColor);
                                 break;
                         }
                     }
                     else if (obj1 is Color)
                         throw new PdfXConformanceException("Colorspace RGB is not allowed.");
                     break;
             }
             break;
         case PDFXKEY_CMYK:
             break;
         case PDFXKEY_RGB:
             if (conf == PdfWriter.PDFX1A2001)
                 throw new PdfXConformanceException("Colorspace RGB is not allowed.");
             break;
         case PDFXKEY_FONT:
             if (!((BaseFont)obj1).IsEmbedded())
                 throw new PdfXConformanceException("All the fonts must be embedded.");
             break;
         case PDFXKEY_IMAGE:
             PdfImage image = (PdfImage)obj1;
             if (image.Get(PdfName.SMASK) != null)
                 throw new PdfXConformanceException("The /SMask key is not allowed in images.");
             switch (conf) {
                 case PdfWriter.PDFX1A2001:
                     PdfObject cs = image.Get(PdfName.COLORSPACE);
                     if (cs == null)
                         return;
                     if (cs.IsName()) {
                         if (PdfName.DEVICERGB.Equals(cs))
                             throw new PdfXConformanceException("Colorspace RGB is not allowed.");
                     }
                     else if (cs.IsArray()) {
                         if (PdfName.CALRGB.Equals(((PdfArray)cs).ArrayList[0]))
                             throw new PdfXConformanceException("Colorspace CalRGB is not allowed.");
                     }
                     break;
             }
             break;
         case PDFXKEY_GSTATE:
             PdfDictionary gs = (PdfDictionary)obj1;
             PdfObject obj = gs.Get(PdfName.BM);
             if (obj != null && !PdfGState.BM_NORMAL.Equals(obj) && !PdfGState.BM_COMPATIBLE.Equals(obj))
                 throw new PdfXConformanceException("Blend mode " + obj.ToString() + " not allowed.");
             obj = gs.Get(PdfName.CA);
             double v = 0.0;
             if (obj != null && (v = ((PdfNumber)obj).DoubleValue) != 1.0)
                 throw new PdfXConformanceException("Transparency is not allowed: /CA = " + v);
             obj = gs.Get(PdfName.ca_);
             v = 0.0;
             if (obj != null && (v = ((PdfNumber)obj).DoubleValue) != 1.0)
                 throw new PdfXConformanceException("Transparency is not allowed: /ca = " + v);
             break;
         case PDFXKEY_LAYER:
             throw new PdfXConformanceException("Layers are not allowed.");
     }
 }
All Usage Examples Of iTextSharp.text.pdf.PdfWriter::IsPdfX