public void CreateComplexXMPTypes() { //ExStart:CreateColorant // create RGB colorant with R, G, B components ColorantRGB rgbColorant = new ColorantRGB(254, 254, 1); // create CMYK colorant with Black, Cyan, Magenta, Yellow components ColorantCMYK cmykColorant = new ColorantCMYK(10, 10, 1, 50); //ExEnd:CreateColorant //ExStart:CreateDimensions int width = 100; int height = 50; // create dimensions Dimensions dimensions = new Dimensions(width, height); dimensions.Units = "inch"; // create dimensions using object initializer Dimensions dimensions2 = new Dimensions(); dimensions2.Width = width; dimensions2.Height = height; dimensions2.Units = "inch"; //ExEnd:CreateDimensions //ExStart:CreateFont string fontFamily = "Arial"; // create Arial font GroupDocs.Metadata.Xmp.Types.Complex.Font.Font font = new GroupDocs.Metadata.Xmp.Types.Complex.Font.Font(fontFamily); //ExEnd:CreateFont //ExStart:CreateResourceEvent // create ResourceEvent type ResourceEvent resourceEvent = new ResourceEvent(); // set the action that occurred resourceEvent.Action = "edited"; // Additional description of the action resourceEvent.Parameters = "secon version"; //ExEnd:CreateResourceEvent //ExStart:CreateResourceRef ResourceRef expectedValue = new ResourceRef { DocumentUri = "074255bf-78bc-4002-89dc-cd7538b40fe0", InstanceId = "42a841b7-48d4-4988-8988-53d2c6e7525d" }; // create XmpMediaManagementPackage XmpMediaManagementPackage package = new XmpMediaManagementPackage(); // update DerivedFrom property package.SetDerivedFrom(expectedValue); // check value ResourceRef value = (ResourceRef)package["xmpMM:DerivedFrom"]; //ExEnd:CreateResourceRef //ExStart:CreateThumbnail // path to the image string imagePath = @"C:\\image.jpg"; string base64String; // use System.Drawing to get image base64 string using (Image image = Image.FromFile(imagePath)) { using (MemoryStream m = new MemoryStream()) { image.Save(m, image.RawFormat); byte[] imageBytes = m.ToArray(); // Convert byte[] to Base64 String base64String = Convert.ToBase64String(imageBytes); } } // xmp thumbnail width int thumbnailWidth = 100; // xmp thumbnail height int thumbnailHeight = 50; // create xmp thumbnail Thumbnail thumbnail = new Thumbnail(thumbnailWidth, thumbnailHeight); // add provide image base64 string thumbnail.ImageBase64 = base64String; //ExEnd:CreateThumbnail //ExStart:CreateVersion // create new instance of Version GroupDocs.Metadata.Xmp.Types.Complex.Version.Version version = new GroupDocs.Metadata.Xmp.Types.Complex.Version.Version(); // set version number version.VersionText = "1.0"; // set version date version.ModifiedDate = DateTime.UtcNow; // set person who modified this version version.Modifier = "Joe Doe"; // set version additional comments version.Comments = "First version, created by: Joe Doe"; //ExEnd:CreateVersion }
public void CreateComplexXMPTypes() { //ExStart:CreateColorant // create RGB colorant with R, G, B components ColorantRGB rgbColorant = new ColorantRGB(254, 254, 1); // create CMYK colorant with Black, Cyan, Magenta, Yellow components ColorantCMYK cmykColorant = new ColorantCMYK(10, 10, 1, 50); //ExEnd:CreateColorant //ExStart:CreateDimensions int width = 100; int height = 50; // create dimensions Dimensions dimensions = new Dimensions(width, height); dimensions.Units = "inch"; // create dimensions using object initializer Dimensions dimensions2 = new Dimensions(); dimensions2.Width = width; dimensions2.Height = height; dimensions2.Units = "inch"; //ExEnd:CreateDimensions //ExStart:CreateFont string fontFamily = "Arial"; // create Arial font GroupDocs.Metadata.Xmp.Types.Complex.Font.Font font = new GroupDocs.Metadata.Xmp.Types.Complex.Font.Font(fontFamily); //ExEnd:CreateFont //ExStart:CreateResourceEvent // create ResourceEvent type ResourceEvent resourceEvent = new ResourceEvent(); // set the action that occurred resourceEvent.Action = "edited"; // Additional description of the action resourceEvent.Parameters = "secon version"; //ExEnd:CreateResourceEvent //ExStart:CreateResourceRef ResourceRef expectedValue = new ResourceRef { DocumentUri = "074255bf-78bc-4002-89dc-cd7538b40fe0", InstanceId = "42a841b7-48d4-4988-8988-53d2c6e7525d" }; // create XmpMediaManagementPackage XmpMediaManagementPackage package = new XmpMediaManagementPackage(); // update DerivedFrom property package.SetDerivedFrom(expectedValue); // check value ResourceRef value = (ResourceRef)package["xmpMM:DerivedFrom"]; //ExEnd:CreateResourceRef //ExStart:CreateThumbnail // path to the image string imagePath = @"C:\\image.jpg"; string base64String; // use System.Drawing to get image base64 string using ( Image image = Image.FromFile(imagePath)) { using (MemoryStream m = new MemoryStream()) { image.Save(m, image.RawFormat); byte[] imageBytes = m.ToArray(); // Convert byte[] to Base64 String base64String = Convert.ToBase64String(imageBytes); } } // xmp thumbnail width int thumbnailWidth = 100; // xmp thumbnail height int thumbnailHeight = 50; // create xmp thumbnail Thumbnail thumbnail = new Thumbnail(thumbnailWidth, thumbnailHeight); // add provide image base64 string thumbnail.ImageBase64 = base64String; //ExEnd:CreateThumbnail //ExStart:CreateVersion // create new instance of Version GroupDocs.Metadata.Xmp.Types.Complex.Version.Version version = new GroupDocs.Metadata.Xmp.Types.Complex.Version.Version(); // set version number version.VersionText = "1.0"; // set version date version.ModifiedDate = DateTime.UtcNow; // set person who modified this version version.Modifier = "Joe Doe"; // set version additional comments version.Comments = "First version, created by: Joe Doe"; //ExEnd:CreateVersion }