Document properties are blank when using a merge


#1

The following code works...




Pdf pdf = new Pdf();
pdf.Author = "Tommy Wang";
pdf.Creator = "Aspose.Pdf";
pdf.Keywords = "Hello World";
pdf.Subject = "Example";
pdf.Title = "Example";
pdf.Save("c:\\test.pdf");

The following code has no effect what so ever...




Document doc = new Document("c:\\k272.pdf.doc");
builder = new DocumentBuilder(doc);
builder.Document.BuiltInDocumentProperties["title"].Value = "Test";
//Save the document in Aspose.Pdf.Xml format into a memory stream.
MemoryStream stream = new MemoryStream();
doc.Save(stream, SaveFormat.FormatAsposePdf);
stream.Seek(0, SeekOrigin.Begin);
//Load the document into an XmlDocument
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(stream);
//Load the XML document into Aspose.Pdf
Pdf pdf = new Pdf();
pdf.IsImagesInXmlDeleteNeeded = true;
pdf.BindXML(xmlDoc, null);
pdf.Author = "Tommy Wang";
pdf.Creator = "Aspose.Pdf";
pdf.Keywords = "Hello World";
pdf.Subject = "Example";
pdf.Title = "TEST";
//doc.BuiltInDocumentProperties["title"].Value.ToString();
//Now produce the PDF file.
pdf.Save("c:\\test.pdf");


I would expect the above to take the word document, add the data to the pdf and create a new pdf on the c: drive. The pdf gets created but the document properties are always blank.

I also tried adding the information to the word document (our real code uses aspose.word to create the document dynamically) but that had no effect either.

Could you have a look please as we'd like to display the course title, the company name and the department name in the property information.

Thanks
--
Stuart


#2

Dear Stuart,

Thank you for considering Aspose.Pdf.

I have tested your code and have not found any error. When I generated the Pdf and press ctrl+D, the document property is correct. The result document is attached.


#3

My appologies, it seems I missed out the bit that appears to be causing the error when I cut and pasted the code. I tried the code I sent you and you are right that it worked correctly. I then started adding in all my code around it to see what was causing the problem. It stopped working again with the following code.



string licenseFile = “Aspose.Custom.lic”;

if (System.IO.File.Exists(licenseFile))

{

Aspose.Word.License wordlicense = new Aspose.Word.License();

license.SetLicense(licenseFile);

}

if (System.IO.File.Exists(licenseFile))

{

Aspose.Pdf.License pdflicense = new Aspose.Pdf.License();

license.SetLicense(licenseFile);

}




Add this at the top of the previous code and run it again.

Its just code to register the licence file in aspose.word and aspose.pdf. Without it the code I sent you created the properties correctly. With it the fields are blank. Hopefully you will see the same when you try it.

#4

I will soon publish a hotfix in which this problem is solved.


#5

This problem has been solved in the new version 2.5.0.0.