The new LINQ reporting engine feature is quite powerful, and provides almost everything that we require. However, the syntax required to get certain formatting is not up to the standards of our high compliance customers. Here is the main use case:
We would like to have an ordered list with different levels, with no space between lines. In order to do that, the template looks like this:
That just won’t do, as the template has a very odd structure that won’t make sense to our users. Is there a way to prevent newlines from coming after <>'s, >'s, and such? Because then we could do this:
This template looks nice, but between every bullet in the resulting document there are four or so newlines.So is there a way to have both: a nice looking template with a nice looking output document. Right now we can only have one of the two.I’ve also attached a word document with the two pages. The first has the template that results in the document that we want. The second has the template layout we want, but the resulting document is not what we want.Thanks!Elliot
Thanks for your inquiry. To ensure a timely and accurate response, please attach the following resources here for testing:
Aspose.Words generated output document which shows undesired output
Your expected document which shows the correct output. Please create this document using Microsoft Word application.
Please create a standalone simplified Java application (source code without compilation errors) that helps us reproduce your problem on our end and attach it here for testing.
As soon as you get these pieces of information ready, we’ll start investigation into your issue and provide you more information. Thanks for your cooperation.
PS: To attach these resources, please zip them and Click ‘Reply’ button that will bring you to the ‘reply page’ and there at the bottom you can include any attachments with that post by clicking the ‘Add/Update’ button.
Thanks for the details. We have logged your requirement in our issue tracking system as WORDSNET-12400. Our product team will further look into the details of this problem and we will keep you updated on the status of this issue. We apologize for any inconvenience.
Please use attached “template.docx” file. The file contains foreach and if tags in separate paragraphs with a hidden font applied. Thus, these tags are present but not seen until the “¶” button is pressed in the MS Word editor.
I have attached the “result.docx” file obtained using this template and LINQ Reporting Engine. Although, the file contains unwanted paragraph breaks, they have a hidden font applied. Thus, these paragraph breaks are not seen as well.
If you want to save the result document using one of non-MS-Word file formats like PDF, then Aspose.Words will not consider hidden paragraphs during conversion by default, so they will not appear in the output.
If you want to save the result document using an MS Word file format, then these paragraphs will not be seen in the output until the “¶” button is pressed in the MS Word editor.
If you will want these paragraph breaks to be completely removed instead of being hidden, this can be achieved with a little bit of coding. Please let us know then and we will provide you a code snippet.
DataSet dataSet = new DataSet();
dataSet.readXml(getMyDir() + "in.xml");
Document document = new Document(getMyDir() + "template.docx");
ReportingEngine engine = new ReportingEngine();
engine.buildReport(document, dataSet);
removeHiddenEmptyParagraphs(document);
document.save(getMyDir() + "result.docx");
private static void removeHiddenEmptyParagraphs(Document document) throws Exception {
NodeCollection paragraphs = document.getChildNodes(NodeType.PARAGRAPH, true);
Paragraph paragraphToRemove = null;
for (Paragraph paragraph : (Iterable<Paragraph>) paragraphs) {
if (paragraphToRemove != null) {
// Remove a paragraph previously marked for removal.
paragraphToRemove.remove();
paragraphToRemove = null;
}
if (!paragraph.hasChildNodes() && paragraph.getParagraphBreakFont().getHidden()) {
// Mark a hidden empty paragraph for removal, but do not remove it straight away,
// since it would break the loop.
paragraphToRemove = paragraph;
}
}
if (paragraphToRemove != null) {
// Remove the last paragraph marked for removal.
paragraphToRemove.remove();
}
}
Regarding WORDSNET-12400, our product team has completed the work on your issue and has come to a conclusion that they won’t be able to implement the fix to your issue. Your issue (WORDSNET-12400) has now been closed with ‘Won’t Fix’ resolution. Please use the workaround mentioned in my previous post.