Hi,
I am not able to reproduce the error, I use the following code with Aspose.Pdf.Kit 3.3.0. Could you please also share the pdf file with us?
1
//set XMP Metadata
2
public static void Test_PdfXmpMetadata()
3
...{
4
string TestPath = @"E:\xmpMeta\";
5
System.Collections.ArrayList keywordlist = new System.Collections.ArrayList();
6
Aspose.Pdf.Kit.PdfXmpMetadata xmpMetaData = new Aspose.Pdf.Kit.PdfXmpMetadata();
7
FileStream input = new FileStream(TestPath + "example1.pdf", FileMode.Open);
8
FileStream output = new FileStream(TestPath + "out.pdf", FileMode.Create);
9
xmpMetaData.InputStream = input;
10
xmpMetaData.OutputStream = output;
11
Aspose.Pdf.Kit.XmpSchema xmp = new Aspose.Pdf.Kit.XmpSchema();
12
string name = @"pdf:TroysTest";
13
string vlu = BuildATag("Nickname",GetBigString(), keywordlist);
14
xmp.AddUserProperty(name,vlu);
15
xmpMetaData.AddXmpRdf(xmp);
16
xmpMetaData.Save();
17
input.Close();
18
output.Close();
19
}
20
//get XMP Metadata
21
public static void Test_PdfXmpMetadata_get()...{
22
string TestPath = @"E:\xmpMeta\";
23
Aspose.Pdf.Kit.PdfXmpMetadata xmpMetaData = new Aspose.Pdf.Kit.PdfXmpMetadata();
24
FileStream input = new FileStream(TestPath + "out.pdf", FileMode.Open);
25
xmpMetaData.InputStream = input;
26
byte [] tem= xmpMetaData.GetXmpMetadata();
27
ASCIIEncoding encoding = new ASCIIEncoding();
28
string constructedString = encoding.GetString(tem);
29
Console.WriteLine(constructedString);
30
}
31
private static string GetBigString()
32
...{
33
StringBuilder sb = new StringBuilder();
34
for (int i = 0; i < 500; i++) sb.Append("0123456789");
35
sb.Append("The End.");
36
return sb.ToString();
37
}
38
static string BuildATag(string tagName, string tagValue, System.Collections.ArrayList keywordList)
39
...{
40
string startTag = string.Format("<{0}>", tagName);
41
string endTag = string.Format("</{0}>", tagName);
42
string aTag = startTag + tagValue + endTag + "\r\n";
43
keywordList.Add(tagValue);
44
return aTag;
45
}
46
Felix Liu
Developer
Aspose Changsha Team
About Us Contact Us