thuliobuarque / java2word

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

Add Image failed #65

Closed GoogleCodeExporter closed 8 years ago

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

Did you download j2w-ejb-2.0.zip or built from the source code?
DOWNLOAD java2word-3.0_2011Aug02.jar

Which web server did you deploy your .WAR (Tomcat, JBoss)?
Will be Tomcat, but testing on non web-app at the moment.

Are you using Maven or Ant?
Maven for xstream

What is your Operational System?

Windows XP and Office Word 2003

What steps will reproduce the problem?
1. Create a new IDocument object.
2. Add image by myDoc.addEle(Image.from_FULL_LOCAL_PATHL(Utils.getAppRoot() + 
"\\src\\test\\resources\\google.png").getContent());
3. save.

Please provide any additional information below.

I have read the issues and seen some people had this problem. However, I do not 
know how to solve it.
I have placed 
System.out.println(Utils.getAppRoot() + "\\src\\test\\resources\\google.png");

before adding the image and it gives me the correct path
"C:\workspace\DownloadManager\src\test\resources\google.png"

But the image added does not display (attached). However, the size of the 
document is 26KB.

Bu if I change the image file to dtpick.gif, the image displays correctly.

attached: 
1. WordImageTest.java: test java file
2. google.png: test image
3. Java2word_allInOne.doc: Created document.
4. Java2word_allInOne.txt: myDoc.getContent() output string.

Original issue reported on code.google.com by jianzhan...@gmail.com on 23 Sep 2011 at 12:51

Attachments:

GoogleCodeExporter commented 8 years ago
The google.png file is not present insite the java2word.jar file.

Are you sure this path is correct: 
C:\workspace\DownloadManager\src\test\resources\google.png

For a simple test, download any image, save it to your desktop or somewhere, 
put the full url to the local file from the root of your system. 

I just downloaded the attached google.png to my desktop folder, in my unit 
test, I added: 

        myDoc.addEle(Paragraph
                .with("This document inside the paragraph, coming from '/src/test/resources/dtpick.gif': "
                        + Image.from_FULL_LOCAL_PATHL(
                                   "/home/leonardo/Desktop/google.png")
                                .getContent()));

and worked. 

Leonardo

Original comment by leonardo...@gmail.com on 25 Sep 2011 at 9:07

GoogleCodeExporter commented 8 years ago

Original comment by leonardo...@gmail.com on 2 Feb 2012 at 12:25