Free Support Forum - aspose.com

Blank fields are displaying after insert DataSet to word Doc

Hi There,

Currently, I am using an evaluation version of aspose.word trying to insert data Model instance to my word document template save as PDF. Through breakpoints, i can see my data in xml and dataset. but once it generates PDF, it shows fields with blanks. i am not sure which step i did wrong or it is the evaluation version problem. Here is my code below. Thank you for helping.

// fetch data to template
public Document createTemplate()
{
Document doc;
doc = new Document(HttpContext.Current.Server.MapPath("~/Content/TestTemplate.docx"));
var serializer = new XmlSerializer(typeof(ReportModel));
var stream = new MemoryStream();
serializer.Serialize(stream, Report1); // Report 1 is an instance of ReportModel with full filled data
using(StreamReader reader = new StreamReader(stream,Encoding.UTF8))
{
stream.Position = 0 ;
var xml = reader.ReadToEnd();
DataSet ds = new DataSet();
ds.ReadXml(new StringReader(xml)); /// i can see report1 data in “xml”
/// after ds read xml , report1 data is still available to see
Doc.MailMerge.UseNonMergeFields= true;
Doc.MailMerge.CleanupOption = MailMergeCleanupOptions.RemoveUnusedFields;
Doc.MailMerge.ExecuteWithRegions(Ds);
}
return Doc;
}
/// Controller Side
public ActionResult Report(int reportID)
{
/// some logic get report1 instance
Document outputDc = createTemplate();
MemoryStream outStream =new MemoryStream();
outputDc.Save(outStream,SaveFormat.Pdf);
outStream.Position = 0;
return File(outStream,“application/pdf”);
}
///Word Template
{{TableStart:ReportModel}}
<< field1>><< field2>><< field3>>
{{TableEnd:ReportModel}}

/// After pdf return, I got the document with data fields of blanks , nothing is showing except evaluation water mark

@Nicksha256,

Thanks for your inquiry. To ensure a timely and accurate response, please ZIP and attach the following resources here for testing:

  • Your simple input Word document
  • Aspose.Words generated output PDF file showing the undesired behavior
  • Please create a standalone simple console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your scenario and provide you more information. Thanks for your cooperation.

Thank you for the reply.

Will the expired evaluation licence or no licence cases prevent fields insert into word template? i mean showing blank fields ?

@Nicksha256,

Please check the following article to know about the limitations.
Evaluate Aspose.Words