I have a scenatio to export a 25000 characters text , which does not have any space break between character. it mean single word with 250000 length . but realtime a word length cannot be more then 25. Anyhow the text should have exported into pdf using Aspose word template. but it doesnot export 25000 length , instead export 4578 characters into pdf , remaining are discarded in pdf. but i could get the 25000 length character in my code before calling that pdf export method using aspose.
But the text are properly exported into pdf , if you give positive scenario text upto any characters length . Let me know, is there any solution why the text are discarded , if gives contineous text without break?
@stilkad,
Thanks for your inquiry. Please ZIP and attach your input Word document here for testing. We will investigate the issue on our side and provide you more information.
wordtemplate.zip (16.6 KB)
Hi Tahir,
I have attached the word template , wihch is rendering the content (attached in notepad) . But the whole contnet does not exported using the word template , that it has cut partially.
C#: logic we assigned the note pad content in variable GeneralVisitComment in a Data table SupervisorComent.
Please look and give solution for this.
Regards,
Anandharaj R
@stilkad,
Thanks for sharing the detail. Please use CompatibilityOptions.GrowAutofit property as shown below to get the desired output. We have attached the output DOCX with this post for your kind reference. 18.4.zip (14.6 KB)
Document doc = new Document(MyDir + "SupervisionReportTemplate - Copy.docx");
DataTable table = new DataTable("SupervisorComment");
table.Columns.Add("GeneralVisitComment", typeof(string));
var newRow = table.NewRow();
newRow["GeneralVisitComment"] = File.ReadAllText(MyDir + "25000 contineous character length.txt", Encoding.Unicode);
table.Rows.Add(newRow);
doc.MailMerge.ExecuteWithRegions(table);
doc.CompatibilityOptions.GrowAutofit = true;
doc.Save(MyDir + "18.4.docx");
@tahir.manzoor,
The autofit is not working as expected. and also the out put document has been in chinease encrypted character. Please find the new 25000 characters and tries to generate again and response.
25000newtext.zip (240 Bytes)
Logic used to generate from my side.
DataSet commentSet = new DataSet();
DataTable table = new DataTable(“SupervisorComment”);
table.Columns.Add(“GeneralVisitComment”, typeof(string));
var newRow = table.NewRow();
newRow[“GeneralVisitComment”] = “”;// get the all 25000 content from the string variable
table.Rows.Add(newRow);
commentSet.Tables.Add(table );
byte[] wordDoc = System.IO.File.ReadAllBytes("word template.docx");
MemoryStream stream = new MemoryStream();
stream.Write(wordDoc, 0, wordDoc.Length);
stream.Flush();
stream.Seek(0, SeekOrigin.Begin);
// Opret dokument fra stream
Aspose.Words.Document doc = new Aspose.Words.Document(stream);
doc.MailMerge.ExecuteWithRegions(commentSet);
MemoryStream outstream = new MemoryStream();
doc.Save(outstream, Aspose.Words.SaveFormat.Pdf); // generatiingpdf document from the word template.
@stilkad,
Thanks for your inquiry. Please do not use CompatibilityOptions.GrowAutofit property in your code when you want to save your document to PDF. If you still face problem, please call Document.UpdateTableLayout method before saving document to PDF.
We have tested the scenario using latest version of Aspose.Words for .NET 18.4 with following code example and have not found the shared issue. Please use Aspose.Words for .NET 18.4. We have attached the output PDF with this post for your kind reference. 18.4.pdf (33.2 KB)
byte[] wordDoc = System.IO.File.ReadAllBytes(MyDir + "SupervisionReportTemplate - Copy.docx");
MemoryStream stream = new MemoryStream();
stream.Write(wordDoc, 0, wordDoc.Length);
stream.Flush();
stream.Seek(0, SeekOrigin.Begin);
Aspose.Words.Document doc = new Aspose.Words.Document(stream);
DataTable table = new DataTable("SupervisorComment");
table.Columns.Add("GeneralVisitComment", typeof(string));
var newRow = table.NewRow();
newRow["GeneralVisitComment"] = File.ReadAllText(MyDir + "25000 contineous character length.txt", Encoding.Unicode);
table.Rows.Add(newRow);
doc.MailMerge.ExecuteWithRegions(table);
doc.Save(MyDir + "18.4.pdf");