karurkarthi / xdocreport

Automatically exported from code.google.com/p/xdocreport
0 stars 0 forks source link

docx -> pdf reporting: merge text with one DOS newline results in two newlines in the PDF #337

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Docx with one MergeField
2. Process report with text containing a DOS newline: \r\n (Velocity engine)
3. PDF contains the text but with two newlines

What is the expected output? What do you see instead?
A sample text "Line 1\r\nLine 2" ends in the Velocity engine as "Line 
1</w:t><w:br/><w:t xml:space=\"preserve\"></w:t><w:br/><w:t 
xml:space=\"preserve\">Line 2"

What version of the product are you using? On what operating system?
1.0.4-SNAPSHOT

Please provide any additional information below.
Apparently, \r and \n are replaced separately. Instead, \r\n should be the 
first replacement.

Correct place for the change should be the class 
DocxTemplateEngineConfiguration.
My workaround is as follows:
lvReport.getTemplateEngine().setConfiguration(new 
AbstractTemplateEngineConfiguration() {

  protected void populate(Collection pvReplacment) {
    pvReplacment.add( new ReplaceText( "\r\n", "</w:t><w:br/><w:t xml:space=\"preserve\">" ) );
    pvReplacment.add( new ReplaceText( "\n", "</w:t><w:br/><w:t xml:space=\"preserve\">" ) );
    pvReplacment.add( new ReplaceText( "\t", "</w:t><w:tab/><w:t xml:space=\"preserve\">" ) );
  }
});

Original issue reported on code.google.com by jarland...@googlemail.com on 27 Nov 2013 at 2:45

GoogleCodeExporter commented 9 years ago
Many thank's for your fix. See Git at 
https://code.google.com/p/xdocreport/source/detail?r=cd8c8ad47b56ed51bc42f906dfd
23569924f3732

Original comment by angelo.z...@gmail.com on 27 Nov 2013 at 9:41

GoogleCodeExporter commented 9 years ago
It's not in the scope of my application, but similar replacements are specified 
in the other configuration classes:

ODTTemplateEngineConfiguration
ODSTemplateEngineConfiguration
ODPTemplateEngineConfiguration

Original comment by jarland...@googlemail.com on 28 Nov 2013 at 4:02

GoogleCodeExporter commented 9 years ago
You ar eright, fixed 
https://code.google.com/p/xdocreport/source/detail?r=8766ec21063cdd521f5c8082dc7
8523f2e35997c

Original comment by angelo.z...@gmail.com on 28 Nov 2013 at 4:08