|
Re: Create a File RTF or PDF whit text formatted and images [message #504569 is a reply to message #504482] |
Mon, 21 December 2009 09:56 |
Grant Gayed Messages: 2150 Registered: July 2009 |
Senior Member |
|
|
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
>
|
|
|
Re: Create a File RTF or PDF whit text formatted and images [message #504973 is a reply to message #504569] |
Wed, 23 December 2009 21:33 |
Antonio Messages: 39 Registered: July 2009 |
Member |
|
|
Hi Grant thanks for your answer,
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
>>
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.02842 seconds