protected internal override void CheckColorsUsages() { if ((rgbIsUsed || cmykIsUsed || grayIsUsed) && pdfAOutputIntentColorSpace == null) { throw new PdfAConformanceException(PdfAConformanceException.IfDeviceRgbCmykGrayUsedInFileThatFileShallContainPdfaOutputIntent ); } if (rgbIsUsed) { if (!ICC_COLOR_SPACE_RGB.Equals(pdfAOutputIntentColorSpace)) { throw new PdfAConformanceException(PdfAConformanceException.DevicergbMayBeUsedOnlyIfTheFileHasARgbPdfAOutputIntent ); } } if (cmykIsUsed) { if (!ICC_COLOR_SPACE_CMYK.Equals(pdfAOutputIntentColorSpace)) { throw new PdfAConformanceException(PdfAConformanceException.DevicecmykMayBeUsedOnlyIfTheFileHasACmykPdfAOutputIntent ); } } }
protected internal override void CheckColorsUsages() { if ((rgbIsUsed || cmykIsUsed || grayIsUsed) && pdfAOutputIntentColorSpace == null) { throw new PdfAConformanceException(PdfAConformanceException.IF_DEVICE_RGB_CMYK_GRAY_USED_IN_FILE_THAT_FILE_SHALL_CONTAIN_PDFA_OUTPUTINTENT ); } if (rgbIsUsed) { if (!ICC_COLOR_SPACE_RGB.Equals(pdfAOutputIntentColorSpace)) { throw new PdfAConformanceException(PdfAConformanceException.DEVICERGB_MAY_BE_USED_ONLY_IF_THE_FILE_HAS_A_RGB_PDFA_OUTPUT_INTENT ); } } if (cmykIsUsed) { if (!ICC_COLOR_SPACE_CMYK.Equals(pdfAOutputIntentColorSpace)) { throw new PdfAConformanceException(PdfAConformanceException.DEVICECMYK_MAY_BE_USED_ONLY_IF_THE_FILE_HAS_A_CMYK_PDFA_OUTPUT_INTENT ); } } }
protected internal override void CheckAnnotation(PdfDictionary annotDic) { PdfName subtype = annotDic.GetAsName(PdfName.Subtype); if (subtype == null) { throw new PdfAConformanceException(PdfAConformanceException.AnnotationType1IsNotPermitted).SetMessageParams ("null"); } if (forbiddenAnnotations.Contains(subtype)) { throw new PdfAConformanceException(PdfAConformanceException.AnnotationType1IsNotPermitted).SetMessageParams (subtype.GetValue()); } PdfNumber ca = annotDic.GetAsNumber(PdfName.CA); if (ca != null && ca.FloatValue() != 1.0) { throw new PdfAConformanceException(PdfAConformanceException.AnAnnotationDictionaryShallNotContainTheCaKeyWithAValueOtherThan1 ); } if (!annotDic.ContainsKey(PdfName.F)) { throw new PdfAConformanceException(PdfAConformanceException.AnnotationShallContainKeyF); } int flags = (int)annotDic.GetAsInt(PdfName.F); if (!CheckFlag(flags, PdfAnnotation.PRINT) || CheckFlag(flags, PdfAnnotation.HIDDEN) || CheckFlag(flags, PdfAnnotation .INVISIBLE) || CheckFlag(flags, PdfAnnotation.NO_VIEW)) { throw new PdfAConformanceException(PdfAConformanceException.TheFKeysPrintFlagBitShallBeSetTo1AndItsHiddenInvisibleAndNoviewFlagBitsShallBeSetTo0 ); } if (subtype.Equals(PdfName.Text) && (!CheckFlag(flags, PdfAnnotation.NO_ZOOM) || !CheckFlag(flags, PdfAnnotation .NO_ROTATE))) { throw new PdfAConformanceException(PdfAConformanceException.TextAnnotationsShouldSetTheNozoomAndNorotateFlagBitsOfTheFKeyTo1 ); } if (annotDic.ContainsKey(PdfName.C) || annotDic.ContainsKey(PdfName.IC)) { if (!ICC_COLOR_SPACE_RGB.Equals(pdfAOutputIntentColorSpace)) { throw new PdfAConformanceException(PdfAConformanceException.DestoutputprofileInThePdfa1OutputintentDictionaryShallBeRgb ); } } PdfDictionary ap = annotDic.GetAsDictionary(PdfName.AP); if (ap != null) { if (ap.ContainsKey(PdfName.D) || ap.ContainsKey(PdfName.R)) { throw new PdfAConformanceException(PdfAConformanceException.AppearanceDictionaryShallContainOnlyTheNKeyWithStreamValue ); } PdfStream n = ap.GetAsStream(PdfName.N); if (n == null) { throw new PdfAConformanceException(PdfAConformanceException.AppearanceDictionaryShallContainOnlyTheNKeyWithStreamValue ); } CheckResourcesOfAppearanceStreams(ap); } if (PdfName.Widget.Equals(subtype) && (annotDic.ContainsKey(PdfName.AA) || annotDic.ContainsKey(PdfName.A) )) { throw new PdfAConformanceException(PdfAConformanceException.WidgetAnnotationDictionaryOrFieldDictionaryShallNotIncludeAOrAAEntry ); } if (annotDic.ContainsKey(PdfName.AA)) { throw new PdfAConformanceException(PdfAConformanceException.AnAnnotationDictionaryShallNotContainAAKey); } if (CheckStructure(conformanceLevel)) { if (contentAnnotations.Contains(subtype) && !annotDic.ContainsKey(PdfName.Contents)) { throw new PdfAConformanceException(PdfAConformanceException.AnnotationOfType1ShouldHaveContentsKey).SetMessageParams (subtype); } } }
protected internal override void CheckAnnotation(PdfDictionary annotDic) { PdfName subtype = annotDic.GetAsName(PdfName.Subtype); if (subtype == null) { throw new PdfAConformanceException(PdfAConformanceException.ANNOTATION_TYPE_0_IS_NOT_PERMITTED).SetMessageParams ("null"); } if (forbiddenAnnotations.Contains(subtype)) { throw new PdfAConformanceException(PdfAConformanceException.ANNOTATION_TYPE_0_IS_NOT_PERMITTED).SetMessageParams (subtype.GetValue()); } PdfNumber ca = annotDic.GetAsNumber(PdfName.CA); if (ca != null && ca.FloatValue() != 1.0) { throw new PdfAConformanceException(PdfAConformanceException.AN_ANNOTATION_DICTIONARY_SHALL_NOT_CONTAIN_THE_CA_KEY_WITH_A_VALUE_OTHER_THAN_1 ); } if (!annotDic.ContainsKey(PdfName.F)) { throw new PdfAConformanceException(PdfAConformanceException.AN_ANNOTATION_DICTIONARY_SHALL_CONTAIN_THE_F_KEY ); } int flags = (int)annotDic.GetAsInt(PdfName.F); if (!CheckFlag(flags, PdfAnnotation.PRINT) || CheckFlag(flags, PdfAnnotation.HIDDEN) || CheckFlag(flags, PdfAnnotation .INVISIBLE) || CheckFlag(flags, PdfAnnotation.NO_VIEW)) { throw new PdfAConformanceException(PdfAConformanceException.THE_F_KEYS_PRINT_FLAG_BIT_SHALL_BE_SET_TO_1_AND_ITS_HIDDEN_INVISIBLE_AND_NOVIEW_FLAG_BITS_SHALL_BE_SET_TO_0 ); } if (subtype.Equals(PdfName.Text) && (!CheckFlag(flags, PdfAnnotation.NO_ZOOM) || !CheckFlag(flags, PdfAnnotation .NO_ROTATE))) { throw new PdfAConformanceException(PdfAConformanceLogMessageConstant.TEXT_ANNOTATIONS_SHOULD_SET_THE_NOZOOM_AND_NOROTATE_FLAG_BITS_OF_THE_F_KEY_TO_1 ); } if (annotDic.ContainsKey(PdfName.C) || annotDic.ContainsKey(PdfName.IC)) { if (!ICC_COLOR_SPACE_RGB.Equals(pdfAOutputIntentColorSpace)) { throw new PdfAConformanceException(PdfAConformanceException.DESTOUTPUTPROFILE_IN_THE_PDFA1_OUTPUTINTENT_DICTIONARY_SHALL_BE_RGB ); } } PdfDictionary ap = annotDic.GetAsDictionary(PdfName.AP); if (ap != null) { if (ap.ContainsKey(PdfName.D) || ap.ContainsKey(PdfName.R)) { throw new PdfAConformanceException(PdfAConformanceException.APPEARANCE_DICTIONARY_SHALL_CONTAIN_ONLY_THE_N_KEY_WITH_STREAM_VALUE ); } PdfStream n = ap.GetAsStream(PdfName.N); if (n == null) { throw new PdfAConformanceException(PdfAConformanceException.APPEARANCE_DICTIONARY_SHALL_CONTAIN_ONLY_THE_N_KEY_WITH_STREAM_VALUE ); } CheckResourcesOfAppearanceStreams(ap); } if (PdfName.Widget.Equals(subtype) && (annotDic.ContainsKey(PdfName.AA) || annotDic.ContainsKey(PdfName.A) )) { throw new PdfAConformanceException(PdfAConformanceException.WIDGET_ANNOTATION_DICTIONARY_OR_FIELD_DICTIONARY_SHALL_NOT_INCLUDE_A_OR_AA_ENTRY ); } if (annotDic.ContainsKey(PdfName.AA)) { throw new PdfAConformanceException(PdfAConformanceException.AN_ANNOTATION_DICTIONARY_SHALL_NOT_CONTAIN_AA_KEY ); } if (CheckStructure(conformanceLevel)) { if (contentAnnotations.Contains(subtype) && !annotDic.ContainsKey(PdfName.Contents)) { throw new PdfAConformanceException(PdfAConformanceException.ANNOTATION_OF_TYPE_0_SHOULD_HAVE_CONTENTS_KEY) .SetMessageParams(subtype.GetValue()); } } }