Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsCreate a File RTF or PDF whit text formatted and images
https://www.eclipse.org/forums/index.php/mv/msg/159694/504482/#msg_504482
i have this problem, i write a RCP and i use SWT library.
In this RCP i create a little WordProcessor, i use styleText library.
I can manipolate text and insert a image.
Now i want to create a file (RTF or PDF), this file have the text formatted
and the images
but i don't have idea that to do.
I see the open source progect itext(http://itextpdf.com/) but i don't know
that i use this libraries whit styledText, can you help me?
best regads
Antonio]]>Antonio2009-12-20T11:10:45-00:00Re: Create a File RTF or PDF whit text formatted and images
https://www.eclipse.org/forums/index.php/mv/msg/159694/504569/#msg_504569
StyledText has inner class RTFWriter, which writes a StyledText's content in
RTF format. Unfortunately this class is not public, so your choices are:
1. Use it indirectly by invoking StyledText.copy(). This writes an RTF
version of your content to the clipboard, which you can get at and save to a
file (example snippet below). The drawback with this approach is that the
user's previous clipboard content gets overwritten.
public static void main(String[] args) {
final Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
final StyledText text = new StyledText(shell, SWT.NONE);
text.addListener(SWT.MouseDoubleClick, new Listener() {
public void handleEvent(Event event) {
text.copy();
Clipboard cb = new Clipboard(display);
RTFTransfer transfer = RTFTransfer.getInstance();
String data = (String)cb.getContents(transfer);
System.out.println(data);
cb.dispose();
}
});
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}
2. Make a public copy of the RTFWriter class.
3. Using introspection you may be able to create an instance of StyledText's
RTFWriter, even though it's not a public class. If this succeeds then you
should be able to use it in place.
I have no idea about creating a PDF, you'll have to look around at third
party libraries. Maybe there's something out there that can create a PDF
from an RTF?
HTH,
Grant
"Antonio De Curtis" <adecurtis99@yahoo.it> wrote in message
news:hgl0mv$rsu$1@build.eclipse.org...
> Hi to all,
>
> i have this problem, i write a RCP and i use SWT library.
>
> In this RCP i create a little WordProcessor, i use styleText library.
>
> I can manipolate text and insert a image.
>
> Now i want to create a file (RTF or PDF), this file have the text
formatted
> and the images
>
> but i don't have idea that to do.
>
> I see the open source progect itext(http://itextpdf.com/) but i don't know
> that i use this libraries whit styledText, can you help me?
>
> best regads
>
> Antonio
>]]>Grant Gayed2009-12-21T09:56:07-00:00Re: Create a File RTF or PDF whit text formatted and images
https://www.eclipse.org/forums/index.php/mv/msg/159694/504973/#msg_504973
i see itextpdf for create a pdf file(this package create pdf, rtf and html
file)
now i'm studing to use this package whit styledtext.
regads
Antonio
"Grant Gayed" <grant_gayed@ca.ibm.com> ha scritto nel messaggio
news:hgo25d$99e$1@build.eclipse.org...
> Hi Antonio,
>
> StyledText has inner class RTFWriter, which writes a StyledText's content
> in
> RTF format. Unfortunately this class is not public, so your choices are:
>
> 1. Use it indirectly by invoking StyledText.copy(). This writes an RTF
> version of your content to the clipboard, which you can get at and save to
> a
> file (example snippet below). The drawback with this approach is that the
> user's previous clipboard content gets overwritten.
>
> public static void main(String[] args) {
> final Display display = new Display();
> Shell shell = new Shell(display);
> shell.setLayout(new FillLayout());
> final StyledText text = new StyledText(shell, SWT.NONE);
> text.addListener(SWT.MouseDoubleClick, new Listener() {
> public void handleEvent(Event event) {
> text.copy();
> Clipboard cb = new Clipboard(display);
> RTFTransfer transfer = RTFTransfer.getInstance();
> String data = (String)cb.getContents(transfer);
> System.out.println(data);
> cb.dispose();
> }
> });
> shell.open();
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch()) display.sleep();
> }
> display.dispose();
> }
>
> 2. Make a public copy of the RTFWriter class.
>
> 3. Using introspection you may be able to create an instance of
> StyledText's
> RTFWriter, even though it's not a public class. If this succeeds then you
> should be able to use it in place.
>
> I have no idea about creating a PDF, you'll have to look around at third
> party libraries. Maybe there's something out there that can create a PDF
> from an RTF?
>
> HTH,
> Grant
>
>
> "Antonio De Curtis" <adecurtis99@yahoo.it> wrote in message
> news:hgl0mv$rsu$1@build.eclipse.org...
>> Hi to all,
>>
>> i have this problem, i write a RCP and i use SWT library.
>>
>> In this RCP i create a little WordProcessor, i use styleText library.
>>
>> I can manipolate text and insert a image.
>>
>> Now i want to create a file (RTF or PDF), this file have the text
> formatted
>> and the images
>>
>> but i don't have idea that to do.
>>
>> I see the open source progect itext(http://itextpdf.com/) but i don't
>> know
>> that i use this libraries whit styledText, can you help me?
>>
>> best regads
>>
>> Antonio
>>
>
>]]>Antonio2009-12-23T21:33:15-00:00