File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes StyledDocuments Image Alignment Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "StyledDocuments Image Alignment" Watch "StyledDocuments Image Alignment" New topic
Author

StyledDocuments Image Alignment

Charles Kent
Greenhorn

Joined: Aug 07, 2008
Posts: 1
Hey everybody, I've got two questions. I've been working on a program which uses a jtextpane+styled document. The document has both text (multiple styles), and one .gif picture.

1)The document looks much like a page of text with the image at the top left. The problem? I want the image at the top right while keeping the text left-aligned. I've tried setCharacterAttributes(), setParagaphAttributes(), and insertString() with right-aligned styleconstants, alas it has not worked. The character attribute call did something funky and put in the image, but at the bottom of the document and right aligned. I input the text via a String[] so I can add the appropriate styles to differnt portions of the document.

2) Is there a way to save a styleddocument file to rtf format with which it includes the picture? I've only been able save the text from the document. Would breaking the document up in 2 and trying to use and ImageIO for one and FileWriter for the text work, trying of course to put it all into the selected name from JFileChooser.

Thanks in advance, any and all help would be appreciated
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: StyledDocuments Image Alignment