thuliobuarque / java2word

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

Unable to write the Special Characters #70

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What web framework and version are you using (Struts1, Struts2, Spring,
JBoss Seam)?

NA

Did you download j2w-ejb-2.0.zip or built from the source code?

Yes

Which web server did you deploy your .WAR (Tomcat, JBoss)?

Weblogic

Are you using Maven or Ant?

NA
What is your Operational System?

Windows Vista

What steps will reproduce the problem?

1. When I try to add special characters like (&.. etc) I am unable to open the 
document that gets created.

Original issue reported on code.google.com by phanindr...@gmail.com on 27 Oct 2011 at 10:59

GoogleCodeExporter commented 8 years ago
Try to set the encoding according to your system.

myDoc.encoding(Encoding.UTF_8);

or

I think you can pass a string: 
myDoc.encoding("whatever string");

cheers
Leonardo Correa

Original comment by leonardo...@gmail.com on 27 Oct 2011 at 11:01

GoogleCodeExporter commented 8 years ago
Hi Leonardo,

I tried both of the encoding procedures the first one didnt work and the second 
one i.e, myDoc.encoding("&");,had given me total xml document of the myDoc. 
What could be the problem? Kindly get back at the earliest.

Thanks,
Phani.

Original comment by phanindr...@gmail.com on 27 Oct 2011 at 12:00

GoogleCodeExporter commented 8 years ago
I think you have to send the & encoded. I will give a try. i will be back in a 
minute...

Original comment by leonardo...@gmail.com on 27 Oct 2011 at 12:03

GoogleCodeExporter commented 8 years ago
Thank you so much Leonardo. I will be waiting for your reply.

Original comment by phanindr...@gmail.com on 27 Oct 2011 at 12:08

GoogleCodeExporter commented 8 years ago
This is it:

    @Test
    public void testTst() {
        IDocument myDoc = new Document2004();        
        myDoc.addEle(Paragraph.with("aaa &").create());
        String myWord = myDoc.getContent();
        TestUtils.createLocalDoc(myDoc.getContent());
    }

I will add to the project page that special characters need to be encoded - not 
change the encoding of the document.

cheers
Leonardo 

Original comment by leonardo...@gmail.com on 27 Oct 2011 at 12:11

GoogleCodeExporter commented 8 years ago

You are lucky man I can't sleep, you ended up getting a on-line support on 
java2word first...

I updated the project page: 
http://code.google.com/p/java2word/#All-in-one_Example_-_See_everything_you_can_
do_with_Java2word

Updated the unit test all-in-one

and committed the unit test code

cheers
Leonardo

Original comment by leonardo...@gmail.com on 27 Oct 2011 at 12:20

GoogleCodeExporter commented 8 years ago
Thank you so much Leonardo for your useful help but there are some characters 
like ®,¥,... like some currency symbols which are not working even though we 
use the escape sequence like what we used for '&' i.e, '&' .Can you please make 
me aware of the procedure in which I can proceed. I know the escape sequences 
for all the other special characters. I proceeded the same way as you suggested 
but ended up in a document which could not open for me. I dont want your normal 
work got disturbed by this so kindly suggest me the way in which I can proceed 
or if you come up with sample code as aboove it would be a great help for me. 

Thanks,
Phani  

Original comment by phanindr...@gmail.com on 27 Oct 2011 at 12:24

GoogleCodeExporter commented 8 years ago
I think if we find a list of stuff to scape, j2w can look up and do the 
replacement. 
don't know... maybe a encoding reference list on google...

I gotta go now but it will work if you find out which character is breaking or 
not getting encoded properly 

Original comment by leonardo...@gmail.com on 27 Oct 2011 at 12:33

GoogleCodeExporter commented 8 years ago
¥ can you please try for this for me? the escape sequence is "¥" please.

Thanks,
Phani.

Original comment by phanindr...@gmail.com on 27 Oct 2011 at 12:43

GoogleCodeExporter commented 8 years ago
myDoc.addEle(Paragraph.with("¥").create());

The trick is: get the decimal number (165), add &#[number here]; and you are 
done:

This list is good, lets keep it handy:
http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references

Original comment by leonardo...@gmail.com on 27 Oct 2011 at 1:02

GoogleCodeExporter commented 8 years ago
Thank you so much Leonardo for your great help and really helpful Java2Word API.

Thanks,
Phani.

Original comment by phanindr...@gmail.com on 27 Oct 2011 at 1:06

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
wiki for encoding is now: 
http://code.google.com/p/java2word/wiki/EncodingTipsandTricks

Original comment by leonardo...@gmail.com on 17 Jan 2012 at 12:34

GoogleCodeExporter commented 8 years ago
Hi Leonardo thanks a lot for the fix..

Regards
Phanindra

Original comment by phanindr...@gmail.com on 8 Oct 2012 at 12:34

GoogleCodeExporter commented 8 years ago
Hey Thanks for the tips but is there any way I can insert "<" and ">" with this 
API.
I would appreciate your reply.
Thanks

Original comment by vrindama...@gmail.com on 13 Jun 2013 at 9:51