/// <summary>
        /// Performs the XMP data extraction, adding found values to the specified instance of
        /// <see cref="Com.Drew.Metadata.Metadata"/>
        /// .
        /// <p/>
        /// The extraction is done with Adobe's XMPCore library.
        /// </summary>
        public virtual void Extract(string xmpString, Com.Drew.Metadata.Metadata metadata)
        {
            XmpDirectory directory = metadata.GetOrCreateDirectory <XmpDirectory>();

            try
            {
                XMPMeta xmpMeta = XMPMetaFactory.ParseFromString(xmpString);
                ProcessXmpTags(directory, xmpMeta);
            }
            catch (XMPException e)
            {
                directory.AddError("Error processing XMP data: " + e.Message);
            }
        }
Example #2
0
 protected override void AddCustomMetadataExtensions(XMPMeta xmpMeta)
 {
     if (this.IsTagged())
     {
         try {
             XMPMeta taggedExtensionMeta = XMPMetaFactory.ParseFromString(PdfAXMPUtil.PDF_UA_EXTENSION);
             XMPUtils.AppendProperties(taggedExtensionMeta, xmpMeta, true, false);
         }
         catch (XMPException exc) {
             ILogger logger = LoggerFactory.GetLogger(typeof(iText.Pdfa.PdfADocument));
             logger.Error(LogMessageConstant.EXCEPTION_WHILE_UPDATING_XMPMETADATA, exc);
         }
     }
 }
Example #3
0
        /// <summary>
        /// Performs the XMP data extraction, adding found values to the specified instance of
        /// <see cref="Com.Drew.Metadata.Metadata"/>
        /// .
        /// <p>
        /// The extraction is done with Adobe's XMPCore library.
        /// </summary>
        public virtual void Extract([NotNull] string xmpString, [NotNull] Com.Drew.Metadata.Metadata metadata)
        {
            XmpDirectory directory = new XmpDirectory();

            try
            {
                XMPMeta xmpMeta = XMPMetaFactory.ParseFromString(xmpString);
                ProcessXmpTags(directory, xmpMeta);
            }
            catch (XMPException e)
            {
                directory.AddError("Error processing XMP data: " + e.Message);
            }
            if (!directory.IsEmpty())
            {
                metadata.AddDirectory(directory);
            }
        }
Example #4
0
 protected override void UpdateXmpMetadata()
 {
     try {
         XMPMeta xmpMeta = UpdateDefaultXmpMetadata();
         xmpMeta.SetProperty(XMPConst.NS_PDFA_ID, XMPConst.PART, checker.GetConformanceLevel().GetPart());
         xmpMeta.SetProperty(XMPConst.NS_PDFA_ID, XMPConst.CONFORMANCE, checker.GetConformanceLevel().GetConformance
                                 ());
         if (this.IsTagged())
         {
             XMPMeta taggedExtensionMeta = XMPMetaFactory.ParseFromString(PdfAXMPUtil.PDF_UA_EXTENSION);
             XMPUtils.AppendProperties(taggedExtensionMeta, xmpMeta, true, false);
         }
         SetXmpMetadata(xmpMeta);
     }
     catch (XMPException e) {
         ILogger logger = LoggerFactory.GetLogger(typeof(iText.Pdfa.PdfADocument));
         logger.Error(LogMessageConstant.EXCEPTION_WHILE_UPDATING_XMPMETADATA, e);
     }
 }
Example #5
0
        /// <summary>Adds the ZUGFeRD RDF description.</summary>
        /// <param name="xmpMeta">the xmp meta</param>
        /// <param name="zugferdConformanceLevel">the zugferd conformance level</param>
        /// <exception cref="iText.Kernel.XMP.XMPException">the XMP exception</exception>
        private void AddZugferdRdfDescription(XMPMeta xmpMeta, ZugferdConformanceLevel zugferdConformanceLevel)
        {
            switch (zugferdConformanceLevel)
            {
            case ZugferdConformanceLevel.ZUGFeRDBasic:
            case ZugferdConformanceLevel.ZUGFeRDComfort:
            case ZugferdConformanceLevel.ZUGFeRDExtended: {
                // fallthrough
                // fallthrough
                XMPMeta taggedExtensionMetaComfort = XMPMetaFactory.ParseFromString(GetZugferdExtension(zugferdConformanceLevel
                                                                                                        ));
                XMPUtils.AppendProperties(taggedExtensionMetaComfort, xmpMeta, true, false);
                break;
            }

            default: {
                break;
            }
            }
        }