Hi,
I have a JSON object and a pre-defined word template. We do provide the JSON object/word document in order to create a PDF file.
The PDF output is pretty good. However, we face an issue in that the subReport generation gets split into 2 pages which does not appear good.
Is there a method of finding out or managing either to move all the SubReport to another page?
I’ve added a template word document and the desired result in pdf.
startList-TeamRelay.docx (29.5 KB)
@tanerkorpe Could you please attach your sample data source and code you use to fill document with data? Also, please attach your current output and expected output documents in MS Word or PDF formats. This will help us to better understand your requirements.
If you need to just prevent table row to break across pages, you can disable this in MS Word:
Hi @alexey.noskov, thanks for your reply.
I have added a sample JSON file of data.
sample.docx (22.7 KB)
I have uploaded a screenshot that depicts the pdf generation from a world doc template.
Screenshot 2023-06-18 at 12.24.12.png (301.7 KB)
The current output was attached earlier in my message. The expected outcome is to keep all the tables-rows together. The report shows “Heat 2 - Female” and it has the name listed underneath. The rows should not be split into multiple table and not on the following page. If a row is gonna fall onto the following page then the whole “Heat 2 - Female” table should move onto the following page.
This is important for us as we serve the community generating these reports. Thanks a lot!
Thanks for the help!
@tanerkorpe To keep rows of the table together you can set ParagraphFormat.KeepWithNext and ParagraphFormat.KeepTogather for the paragraphs in the table.
Could you please provide source of the FunctionUtilities.ConvertJsongToDataset
method, in text format if possible? So I can test your scenario on my side. Or create a simple console application with code required to reproduce the problem. This will really help us to better assist you.
Thanks Alexey.
I did use those properties and it didn’t help. I applied KeepWithNext which has to be done by looping through Doc,Rows.
As my code shows that we don’t use DocumentBuilder. It is only Document class and a json provided to it.
ConvertJsonToDataset method is as follows:
public static DataSet ConvertJsonToDataset(string jsonData)
{
XmlDocument Xml = JsonConvert.DeserializeXmlNode(jsonData);
DataSet ds = new DataSet();
ds.ReadXml(new MemoryStream(Encoding.UTF8.GetBytes(Xml.InnerXml)));
return ds;
}
Any help would be appreciated!
Thanks
@tanerkorpe Thank you for additional information. Unfortunately, I cannot reproduce the problem on my side using the provided template data and code. Here is the test code I have used:
Document doc = new Document(@"C:\Temp\in.docx");
DataSet ds = ConvertJsonToDataset(File.ReadAllText(@"C:\Temp\data.json"));
doc.MailMerge.ExecuteWithRegions(ds);
doc.Save(@"C:\Temp\out.pdf");
public static DataSet ConvertJsonToDataset(string jsonData)
{
XmlDocument Xml = JsonConvert.DeserializeXmlNode(jsonData);
DataSet ds = new DataSet();
ds.ReadXml(new MemoryStream(Encoding.UTF8.GetBytes(Xml.InnerXml)));
return ds;
}
Here is the output PDF document: out.pdf (47.8 KB)
If possible, please, create a simple console application with code, documents and data required to reproduce the problem. This will really help us to better assist you.
I’ve attached a console app that has a template doc and a sample JSON file. The code does generate a pdf in the project bin folder. I cannot produce the table separation with this console application. foo-thelatest look PDF has a overlap with the separation line though that I am not too concerned. As I attached a faulty PDF in my early message which has a table separation.
Any guidance would be much appreciated!
the code
https://stcar6l433y3rjudev.blob.core.windows.net/test/eventumrts.consoleapp.zip
@tanerkorpe Unfortunately, I still cannot reproduce the problem on my side. Here is PDF document produced on my side using your application: foo-error.pdf (79.7 KB)
I have also tried increasing number of rows in the tables, but still the tables are rendered correctly.
Thanks.
As long as there is no possible way to produce the report with the tables apart from a page to page using the template doc then I’d say this is a good outcome.
I don’t know how it was coming up with an incorrect formatting.
@tanerkorpe I have managed to reproduce a kind of the problematic output if make SubReport
table not floating: foo-error.pdf (79.6 KB).
But if mark two first rows in the table as header row in the table, the output looks good again. here is the modified template and output: startList-error.docx (73.6 KB)
out.pdf (79.7 KB)
So you modified the word doc template therefore it works okay?
Can you specify what exactly changes you applied in the word doc template so that we can apply the same thing to other types of templates we have?
thanks
@tanerkorpe The output I have attached in this reply has been produced by your code and template without any modifications.
The output foo-error.pdf
attached in this reply was produced by your code and modified template. The table has been made inline:
The
out.pdf
was produced by your code and modified template I have attached. The table has been made inline and the first two rows of the table have been parked as header rows:
thanks - I will apply this.
1 Like