StimVinsh / xdocreport

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

Text Styling with HTML Code // leading blank line #127

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
- What steps will reproduce the problem?

1. Using Text Styling with HTML and Word documents, this issue also occurs with 
OpenOffice and in the Demo WebApp

2. We want to style a text and also to support carriage return (new lines) from 
a HTML textarea input field.

3. XDocReport support only the <p>any text</p> syntax with these issues:

a) <p>any text</p> causes a leading blank new line, that could not removed?!
b) In the Word document the paragraph style will not used from the MergeField 
style because of this spare paragraph
c) A <br/> tag is not supported without a paragraph change

- What is the expected output? What do you see instead?

Would it be difficult to insert a "simple" new line command for this issue or 
could the blank new line be removed?

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

We tested this behaviour with version 0.9.7

- Please provide any additional information below.

We are interested to use this tool. In witch classes and jars is the text 
styling with HTML implemented?

There is also a issues with processing (German) umlauts like ä,ö,ü used via 
&auml; &uuml; etc.. I think the French accent aigu will cause the same 
defective XML and DOCX files?!?

Original issue reported on code.google.com by googlec...@norz.de on 4 Jul 2012 at 12:10

GoogleCodeExporter commented 8 years ago
Hi,

> 2. We want to style a text and also to support carriage return (new lines) 
from a HTML textarea input field.

I have decided to remove '\n' and '\r' because it's, because it's HTML ignore 
those caracters. Ex: if you create an simple HTML file : 

---------------------
<html>
<body>
a
b
</body>
</html>
---------------------

Browser (FF, Chrome, etc...) displays : 

---------------------
a b
---------------------

If you see the text syling demo webapp 
(http://xdocreport.opensagres.cloudbees.net/textStyling.jsp), it uses CKEditor 
which generates '\n', '\r' and it must be ignored.

> a) <p>any text</p> causes a leading blank new line, that could not removed?!
When you set a field with html text styling in docx or odt, you have (for odt)
<p:text>$field</p:text>

So if $field="a b", it will generate :

---------------------
<p:text>a b</p:text>
---------------------

if $field="<p>a b</p>", it will generate 

---------------------
<p:text></p:text>
<p:text>a b</p:text>
---------------------

It's the case you describe. So why do you not use "a b" instead of <p>a b</p>?

>b) In the Word document the paragraph style will not used from the MergeField 
style because of this spare paragraph

Could you tell me a sample (docx+java code) please?

>c) A <br/> tag is not supported without a paragraph change
Could you tell me a sample (docx+java code) please?

> We are interested to use this tool. In witch classes and jars is the text 
styling with HTML implemented?

1) 
http://code.google.com/p/xdocreport/source/browse/document/fr.opensagres.xdocrep
ort.document/src/main/java/fr/opensagres/xdocreport/document/textstyling/html/HT
MLTextStylingContentHandler.java it a SAX Handler which parse HTML and call the 
well methods of generic documentHandler

2) 
http://code.google.com/p/xdocreport/source/browse/document/fr.opensagres.xdocrep
ort.document/src/main/java/fr/opensagres/xdocreport/document/textstyling/html/HT
MLTextStylingTransformer.java HTML text styling which ignore the '\r, '\n' and 
call the SAX Handler HTMLTextStylingContentHandler

>There is also a issues with processing (German) umlauts like ä,ö,ü used via 
ä >ü etc.. I think the French accent aigu will cause the same defective XML 
and >DOCX files?!?

Yes you are right, the demo webapp failed with 'é'. Please create a separate 
issue for that. Many thank's 

Regards Angelo

Original comment by angelo.z...@gmail.com on 4 Jul 2012 at 1:00

GoogleCodeExporter commented 8 years ago
Hi Angelo, thanks for your quick response!

We also use CKEditor and I think other RichText2HTML Editors will generate HTML 
Code like this:

<p>First Line and Return</p>
<p>Second Line and Shift+Return<br />
Thirst Line and Return</p>
<p>Last Line and nothing else</p>

XDocReport generates (in ODT and DOCX):

An additional Blank Line
First Line and Return
Second Line and Shift+ReturnThirst Line and Return
Last Line and nothing else

CKEditor (and others) cannot omit only the first <p> element, so everyone who 
uses Text Styling have to code a workaround.

Would it make sense to detect leading <p> element and to omit the blank new 
line inside XDocReport?

The same behaviour is if you are using the Wiki syntaxes or the <h1> element, 
see here 
http://xdocreport.opensagres.cloudbees.net/processReport?dispatch=load&reportId=
ODTTextStylingWithFreemarker.odt

I think b) will be caused by a). I'm not sure, but actually that is not so 
important.

For c) That the <br> element will be ignored is shown above too.

Thanks for your additional information. I will have a look and add an new issue 
for umlauts.

Best Regards,

Alexander

Original comment by googlec...@norz.de on 4 Jul 2012 at 1:51

GoogleCodeExporter commented 8 years ago
Hi Alexander,

I think the problem that you have is 

1) <br> is ignored. 
2) extra blank for new line

So if <br> is managed I think you will have not problem and \n must be ignored 
as today.

> For c) That the <br> element will be ignored is shown above too.
I have created a new isse to manage <br /> => 
http://code.google.com/p/xdocreport/issues/detail?id=130

Omit the blank new line is very difficult (I could explain more if you wish), 
but I think we could omit it for simple cas like this : 

------------------------------------
<w:p> 
  <w:t>$html</w:t>
<w:p>
------------------------------------

but not with $html a
> I will have a look and add an new issue for umlauts.
I have seen that (http://code.google.com/p/xdocreport/issues/detail?id=129) and 
I have dixed the problem for the 0.9.8 which will come soon.

Original comment by angelo.z...@gmail.com on 8 Jul 2012 at 8:37

GoogleCodeExporter commented 8 years ago

Original comment by angelo.z...@gmail.com on 28 Sep 2012 at 9:34