本文整理匯總了C#中iTextSharp.text.pdf.PdfWriter.IsPdfX方法的典型用法代碼示例。如果您正苦於以下問題:C# PdfWriter.IsPdfX方法的具體用法?C# PdfWriter.IsPdfX怎麽用?C# PdfWriter.IsPdfX使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類iTextSharp.text.pdf.PdfWriter
的用法示例。
在下文中一共展示了PdfWriter.IsPdfX方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: CheckPDFXConformance
/**
* 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.");
}
}
示例2: CheckPDFXConformance
/**
* 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(MessageLocalization.GetComposedMessage("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 BaseColor)
throw new PdfXConformanceException(MessageLocalization.GetComposedMessage("colorspace.rgb.is.not.allowed"));
break;
}
break;
case PDFXKEY_CMYK:
break;
case PDFXKEY_RGB:
if (conf == PdfWriter.PDFX1A2001)
throw new PdfXConformanceException(MessageLocalization.GetComposedMessage("colorspace.rgb.is.not.allowed"));
break;
case PDFXKEY_FONT:
if (!((BaseFont)obj1).IsEmbedded())
throw new PdfXConformanceException(MessageLocalization.GetComposedMessage("all.the.fonts.must.be.embedded.this.one.isn.t.1", ((BaseFont)obj1).PostscriptFontName));
break;
case PDFXKEY_IMAGE:
PdfImage image = (PdfImage)obj1;
if (image.Get(PdfName.SMASK) != null)
throw new PdfXConformanceException(MessageLocalization.GetComposedMessage("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(MessageLocalization.GetComposedMessage("colorspace.rgb.is.not.allowed"));
}
else if (cs.IsArray()) {
if (PdfName.CALRGB.Equals(((PdfArray)cs)[0]))
throw new PdfXConformanceException(MessageLocalization.GetComposedMessage("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(MessageLocalization.GetComposedMessage("blend.mode.1.not.allowed", obj.ToString()));
obj = gs.Get(PdfName.CA);
double v = 0.0;
if (obj != null && (v = ((PdfNumber)obj).DoubleValue) != 1.0)
throw new PdfXConformanceException(MessageLocalization.GetComposedMessage("transparency.is.not.allowed.ca.eq.1", v));
obj = gs.Get(PdfName.ca_);
v = 0.0;
if (obj != null && (v = ((PdfNumber)obj).DoubleValue) != 1.0)
throw new PdfXConformanceException(MessageLocalization.GetComposedMessage("transparency.is.not.allowed.ca.eq.1", v));
break;
case PDFXKEY_LAYER:
throw new PdfXConformanceException(MessageLocalization.GetComposedMessage("layers.are.not.allowed"));
}
}