Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Tutorial to SWT for Printing
Tutorial to SWT for Printing [message #462149] |
Fri, 07 October 2005 10:23 |
Eclipse User |
|
|
|
Originally posted by: bp.maximuss.dk
Hi
Is there any that know where to find a good tutorial to SWT Printing ??
I have tryed Google but could not really find anything usefull.
Regards
Bjarne
|
|
|
Re: Tutorial to SWT for Printing [message #462151 is a reply to message #462149] |
Fri, 07 October 2005 10:27 |
Eclipse User |
|
|
|
Originally posted by: friederich.kupzog.de
Hi Bjarne,
as far as I am aware there is no such tutorial. There are some useful
snippets though.
I developed a printing library "KPrint" for SWT, which you can get from
http://www.kupzog.de/fkmk_uk/Programming/Downloads/downloads .html
Maybe this helps. You can at least have a look how things are done.
Regards,
Friederich
Bjarne wrote:
> Hi
>
> Is there any that know where to find a good tutorial to SWT Printing ??
> I have tryed Google but could not really find anything usefull.
>
> Regards
>
> Bjarne
--
Friederich Kupzog
Elektronik & Software
Neusser Str. 5-7
50670 Köln
Tel 0241 160696-1
Fax 0221 726670
www.kupzog.de/fkmk
|
|
| |
Re: Tutorial to SWT for Printing [message #462164 is a reply to message #462152] |
Fri, 07 October 2005 13:07 |
Eclipse User |
|
|
|
Originally posted by: friederich.kupzog.de
Hi,
your impression is wrong. You get a print preview first, but you can
print with KPrint on "real paper" with or without preview.
Have a look again.
Regards,
Friederich
arne anka wrote:
>> I developed a printing library "KPrint" for SWT
>
>
> from the "flyer" i understand, that your liberary creates a
> screen-representation of the stuff to print, but it does not actually
> print -- am i right?
> i'm still looking for a useful _platform-independent_ print-solution
> which really prints to paper.
--
Friederich Kupzog
Elektronik & Software
Neusser Str. 5-7
50670 Köln
Tel 0241 160696-1
Fax 0221 726670
www.kupzog.de/fkmk
|
|
| | |
Re: Tutorial to SWT for Printing [message #462189 is a reply to message #462185] |
Fri, 07 October 2005 16:14 |
Eclipse User |
|
|
|
Originally posted by: friederich.kupzog.de
Ok, I only tested KPrint on Windows. It is at least platform independent
until it you try to print the preview/document. The print functionality
makes use of the org.eclipse.swt.printing.Printer class. From the api
doc, also this seems to be platform-independent. But from the answer of
Arne Anka this class seems to cause problems of linux?
Well, I would suggest trying it. If you need any help, I am happy to
assist you with KPrint matters.
Regards,
Friederich
snpe wrote:
> arne anka wrote:
>
>
>>>your impression is wrong. You get a print preview first, but you can
>>>print with KPrint on "real paper" with or without preview.
>>
>>on all supported platforms (primarily linux/gtk)?
>>even eclipse/linux-gtk supports no printing because swt does not in a
>>platform independent way and thus it's simply not done (for several years
>>now, don't know whom they are waiting for ...)
>
>
> this blam for eclipse (I like eclipse, but no printing on all platforms ...)
--
Friederich Kupzog
Elektronik & Software
Neusser Str. 5-7
50670 Köln
Tel 0241 160696-1
Fax 0221 726670
www.kupzog.de/fkmk
|
|
| |
Re: Tutorial to SWT for Printing [message #462202 is a reply to message #462194] |
Fri, 07 October 2005 22:56 |
Eclipse User |
|
|
|
Originally posted by: friederich.kupzog.de
snpe wrote:
> i try KPrintExample on linux gtk - 'Seite einrichtung' is fine,
> i get preview when click on ok - preview is ok, when click
> printer icon nothing happen
Ok, that sounds like something in the PrintDialog class is not
implemented for Linux. Any comments from "SWT officials"?
Basically, the follwing code is executed and I guess it ends because
"data" is null.
protected void onPrint()
{
PrintDialog dialog = new PrintDialog(guiShell, SWT.BORDER);
PrinterData data = dialog.open();
if (data == null) return;
Printer printer = new Printer(data);
GC gc = new GC(printer);
printer.startPage();
document.draw();
printer.endPage();
printer.endJob();
gc.dispose();
printer.dispose();
}
Regards,
Friederich
--
Friederich Kupzog
Elektronik & Software
Neusser Str. 5-7
50670 Köln
Tel 0241 160696-1
Fax 0221 726670
www.kupzog.de/fkmk
|
|
| | | | | | |
Re: Tutorial to SWT for Printing [message #462232 is a reply to message #462226] |
Sat, 08 October 2005 21:28 |
Eclipse User |
|
|
|
Originally posted by: friederich.kupzog.de
arne anka wrote:
> friedrich, is there a way, you extend your library to create postscript
> and, maybe, even make an eclipse-plugin providing "printing for linux"
> (i e take a configured printing frontend and pipe postscript into) from
> it? that would be really great!
Well, postscript sound for me like a good approach. But I have no idea
how to generate postscript. I come from the Windows world and we seem to
be a bit blind on that eye :) But as far as I understand it is nothing
else than a textual text and object position description, right?
So, for KPrint I would need to know
- how to start/end a page
- how to define page size
- how to print a string in font x size y at postion a,b
- how to draw a line from A to B in width c
- how to draw a bitmap at position x,y.
Can anyone help me with that or point me to a good ps file format
description/tutorial? If it is not too complex, I would do it in my
spare time, if I find some :)
> i would do it myself but i still don't know enough about
> eclipse-plugins :-(
Me neither. Unfortunately.
Regards,
Friederich
--
Friederich Kupzog
Elektronik & Software
Neusser Str. 5-7
50670 Köln
Tel 0241 160696-1
Fax 0221 726670
www.kupzog.de/fkmk
|
|
|
Re: Tutorial to SWT for Printing [message #462234 is a reply to message #462232] |
Sun, 09 October 2005 00:09 |
Haris Peco Messages: 1072 Registered: July 2009 |
Senior Member |
|
|
Friederich,
Postscript is open format and have good documentation
see this http://partners.adobe.com/public/developer/ps/index_specs.ht ml
There are Windows driver for postscript, too see
http://support.microsoft.com/kb/142057/EN-US/
and there are Adobe Windows PPD drivers
http://www.adobe.com/support/downloads/detail.jsp?ftpID=204
When you have postscript file you can print to postscript capable printer
directly or with postcript-to-printer driver - Unix/Linux do this
ghostscript program convert ps file to printer device file
cups,lprd and another programs are clients only - all print on same way
Friederich Kupzog wrote:
>
> Well, postscript sound for me like a good approach. But I have no idea
> how to generate postscript. I come from the Windows world and we seem to
> be a bit blind on that eye :) But as far as I understand it is nothing
> else than a textual text and object position description, right?
> So, for KPrint I would need to know
>
> - how to start/end a page
> - how to define page size
> - how to print a string in font x size y at postion a,b
> - how to draw a line from A to B in width c
> - how to draw a bitmap at position x,y.
>
> Can anyone help me with that or point me to a good ps file format
> description/tutorial? If it is not too complex, I would do it in my
> spare time, if I find some :)
>
|
|
|
Re: Tutorial to SWT for Printing [message #462249 is a reply to message #462232] |
Sun, 09 October 2005 18:52 |
Ivan Markov Messages: 61 Registered: July 2009 |
Member |
|
|
Friederich,
> So, for KPrint I would need to know
>
> - how to start/end a page
> - how to define page size
> - how to print a string in font x size y at postion a,b
> - how to draw a line from A to B in width c
> - how to draw a bitmap at position x,y.
If it was *that* simple.. ;)
OK, seriously, the big challenge of doing decent PostScript rendering is to
do the font subsetting and embedding stuff correctly.
You need these because otherwise you have to rely to the Base-14 set of
PostScript fonts (embedded in every PostScript printer).
These are not the best choice because:
- They only cover western alphabets
- You don't get WYSIWYG between printer and screen
Even with the Base-14 set, you have to dig up the *Font Metrics* for these
from the Adobe site (PostScript is adome thingy) and use+embed these in your
code, as GC.getFontMEtrics & GC.stringExtend() have to work or almost
nothing will print correctly.
It is a very interesting topic and I've done something for my SWT/Fox port
in this area, but it is coded in C++
What I would advise you is to:
- Forget about PostScript
- Wait for Cairo to stabilize the PS & PDF backends
- Use Cairo+PDF/PS backend+CUPS to do the printing stuff
Or even better yet:
Wait for official SWT dev to wire SWT to CUPS. SWT's GC on GTK+ is already
wired to Cairo, for the advanced graphics support.
-I
>
> Can anyone help me with that or point me to a good ps file format
> description/tutorial? If it is not too complex, I would do it in my
> spare time, if I find some :)
>
> > i would do it myself but i still don't know enough about
> > eclipse-plugins :-(
> Me neither. Unfortunately.
>
> Regards,
> Friederich
>
> --
> Friederich Kupzog
> Elektronik & Software
> Neusser Str. 5-7
> 50670 K
|
|
|
Re: Tutorial to SWT for Printing [message #462256 is a reply to message #462249] |
Mon, 10 October 2005 02:00 |
Haris Peco Messages: 1072 Registered: July 2009 |
Senior Member |
|
|
Ivan,
Read draft of birt project - they have plan for printing similar my
suggestion.
Cairo will resolve problem for Linux, but what about Mac etc ...
Postscript resolve problem everywhere
Ivan Markov wrote:
> Friederich,
>
>> So, for KPrint I would need to know
>>
>> - how to start/end a page
>> - how to define page size
>> - how to print a string in font x size y at postion a,b
>> - how to draw a line from A to B in width c
>> - how to draw a bitmap at position x,y.
>
> If it was *that* simple.. ;)
> OK, seriously, the big challenge of doing decent PostScript rendering is
> to do the font subsetting and embedding stuff correctly.
> You need these because otherwise you have to rely to the Base-14 set of
> PostScript fonts (embedded in every PostScript printer).
> These are not the best choice because:
> - They only cover western alphabets
> - You don't get WYSIWYG between printer and screen
> Even with the Base-14 set, you have to dig up the *Font Metrics* for these
> from the Adobe site (PostScript is adome thingy) and use+embed these in
> your code, as GC.getFontMEtrics & GC.stringExtend() have to work or almost
> nothing will print correctly.
>
> It is a very interesting topic and I've done something for my SWT/Fox port
> in this area, but it is coded in C++
>
> What I would advise you is to:
> - Forget about PostScript
> - Wait for Cairo to stabilize the PS & PDF backends
> - Use Cairo+PDF/PS backend+CUPS to do the printing stuff
>
> Or even better yet:
> Wait for official SWT dev to wire SWT to CUPS. SWT's GC on GTK+ is already
> wired to Cairo, for the advanced graphics support.
>
>
> -I
>
>
>>
>> Can anyone help me with that or point me to a good ps file format
>> description/tutorial? If it is not too complex, I would do it in my
>> spare time, if I find some :)
>>
>> > i would do it myself but i still don't know enough about
>> > eclipse-plugins :-(
>> Me neither. Unfortunately.
>>
>> Regards,
>> Friederich
>>
>> --
>> Friederich Kupzog
>> Elektronik & Software
>> Neusser Str. 5-7
>> 50670 K
|
|
| | | | | | |
Re: Tutorial to SWT for Printing [message #462275 is a reply to message #462269] |
Mon, 10 October 2005 09:45 |
Eclipse User |
|
|
|
Originally posted by: friederich.kupzog.de
arne anka wrote:
> to Friedrich:
> how do you create your printable right now? i would think you have to
> create a printable already which may be easely converted into
> postscript -- there are several approaches out there already providing
> that ability, i think.
I draw an a GC which was created with the Printer Object as constructor
argument.
Can you point me to some of the approaches you mentioned?
Regards,
Friederich
--
Friederich Kupzog
Elektronik & Software
Neusser Str. 5-7
50670 Köln
Tel 0241 160696-1
Fax 0221 726670
www.kupzog.de/fkmk
|
|
| | |
Re: Tutorial to SWT for Printing [message #462286 is a reply to message #462269] |
Mon, 10 October 2005 13:29 |
Ivan Markov Messages: 61 Registered: July 2009 |
Member |
|
|
Arne,
> > What I would advise you is to:
> > - Forget about PostScript
>
> Postscript is an open approach used succesfully for years (if not decades)
> now. i don't think we should forget about it.
Please, take a look at Cairo before commenting.
What I'm suggesting to Friedrich is to use PostScript/PDF *indirectly*
through Cairo, because
- Cairo already has these backends, although still unstalbe
- org.eclipse.swt.graphics.GC is already wired to Cairo. Shall I explain
what this means?
- The pain of doing font subsetting & embedding will be avoided - Cairo
should do that for Friedrich
Yes, this may require patches against SWt/GTK+, Cairo or both, but *this* is
the way to create a long-term, reliable printing solution.
Doing yet-another PostScript renderer from Java will take too much time, and
eventually will be superseded by the "real", probably Cairo-based SWT/GTK+
printing solution, when it comes out.
> > Or even better yet:
> > Wait for official SWT dev to wire SWT to CUPS.
>
> waiting for the "official swt" on such a crucial issue has turned out to
> be in vain. it ends up with being fed up with hope ad calendas graecas but
> no useful solution.
I'm in no way affiliated with the regular SWT devs.
But, I dare say I know enough of SWT to feel that the GTK printing support
is nearing. If you have the eyes you'll see - the infrastructure is already
there, although for a different purpose.. Yes, I'm referring again to GC
using Cairo for advanced graphics support.
-I
|
|
| |
Re: Tutorial to SWT for Printing [message #462290 is a reply to message #462277] |
Mon, 10 October 2005 13:43 |
Ivan Markov Messages: 61 Registered: July 2009 |
Member |
|
|
Friedrich,
All the links below fall in one of two categories:
- Java2D used for printing. If you can live with that, OK. Note: the .ps
files generated by Java2D are *huge*. I can explain why, if you are
interested.
- Roll-my-own Java-to-Postscript renderer. Either commercial (no-go for you)
or free, but primitive (PsGr - no font embedding, subsetting, and no *font
metrics*).
If you really want to go for the I'll-do-PostScript-from-Java-myself path,
which I don't recommend, you may need:
- The PS reference manuals (from the Adobe site, can't dig up the links
right now) - you *need* to know what Type1, Type3, Type4 PostScript fonts
are
- This (http://eyegene.ophthy.med.umich.edu/lasi/) is nice, as it shows a
primitive way of embedding (sorta) fonts (I think that's the approach Java2D
uses as well, which results in the gigantic .ps files)
- The printing driver in Qt/X11. Note that this is GPL code - you may be
tainted by looking at it, I don't know..
- This may also be useful:
http://cvs.sourceforge.net/viewcvs.py/swtfox/swt-fox/fox-pat ches/FXDCPrint.cpp?rev=1.10&view=auto
-I
"arne anka" <arne.anka@ginguppin.de> wrote in message
news:op.syfef0ifuyrgnr@komhem...
> > Can you point me to some of the approaches you mentioned?
> as usually i've seen most of them by looking for an easy way to print from
> java at all -- because my intended audience would use rather windows than
> any other os i dismissed them all together, trusting in google to find
> again if needed ;-)
>
>
http://java.sun.com/developer/onlineTraining/Programming/JDC Book/advprint.html
> that's what i used (probaly the same idea as you use), i'm still unsure
> how it works ;-) and use it for single page only.
>
> http://acg.media.mit.edu/people/fry/explain/postscript/
> http://www.geocities.com/SiliconValley/5682/Programming.html and from
> there -> http://schmidt.devlib.org/java/libraries-postscript.html
>
> http://www.lightsaber.com/project3PO/java2d-pstext.html <- this sounds
> best, but seems to stall since 5 years (but probably still a good
> foundation to build on?)
>
> if i remember right there's a project connected to apache providing
> creation of postscript, but can't remember the name.
>
> sometimes it looks like java is natively able to produce postscript, but i
> could not verify that ...
> the last approach i used, because i had to to create multipage documents,
> was to create a multipage pdf and send it to an pdf-viewer, but linux and
> other *ces too are able to print pdf.
>
> http://www.lowagie.com/iText/
> as pdf and ps are related it might be useful.
|
|
|
Re: Tutorial to SWT for Printing [message #462323 is a reply to message #462288] |
Mon, 10 October 2005 13:57 |
Ivan Markov Messages: 61 Registered: July 2009 |
Member |
|
|
My dear friend,
I'm sorry if I offended you in any way, but this:
<snip>
> - windows users are lazy for download added software (except Microsoft's
> software and antivirus :) ) - postcript is de-facto standard for printing
> (printer can be postcript native and it is the best printers)
> Birt project will make postscirpt for own usage
</snip>
writing of yours sounded to me as if you suggest that PostScript is *the*
printing API on Windows as well.
If this is not what you meant - I'm sorry, I guess it all comes down to the
fact that English is not my mother tongue.. ;)
As for your issue being the _printing_in_linux_, (or you mean, printing in
SWT/GTK+, as SWT/Motif does work with Xprint, kinda) I reassure you, I
perfectly understand that.. ;)
"arne anka" <arne.anka@ginguppin.de> wrote in message
news:op.syfmmvfeuyrgnr@komhem...
> > supports, this is NOT the solution for Windows. The printing API on
> > Windows
> > is GDI. Deal with it.
>
> boy, whenever did you deal with that non-windows, non-mac-user were unable
> to print? you were obviously not interested in a solution for user _not_
> using windows, so please stay silent if those discuss a way to get a
> functionality provided by the windows-port of eclipse already!
>
> if you have read right you would have understood that our issue is
> _printing_in_linux_! nobody wants the windows-user to miss the
> printing-facility, but we expect to be treated likewise -- and the guys at
> swt were for years now unable to provide _any_ meaningful solution to
> print, an issue you most likely never noticed.
|
|
| | |
Re: Tutorial to SWT for Printing [message #462384 is a reply to message #462286] |
Tue, 11 October 2005 19:00 |
Eclipse User |
|
|
|
Originally posted by: friederich.kupzog.de
Hi all,
after all that discussion I was able to get a sort of overview over the
problem and possible solutions involving KPrint. Since I am not using
Linux I am personally not effected by the problem "no Eclipse print
support for Linux". However, I would spend some time on it if this
solves a realy big problem - which it seems to be after all that
response in this thread.
Still I am not sure if KPrint is the right "medium" to offer a solution.
My KPrint library is a printing layout tool for programmatically
generated documents. It offers special "design" functionality but at the
same time restricts the user to using the KPrint layout concept. As far
as I can see from other thread contributions the basic problem is that
on Linux it is not implemented to use a SWT GC on a Printer. A solution
to this (using Cairo?) would be a more useful approach than adding PS
export features to KPrint. But in this case, KPrint would have not a lot
to do with the problem any more.
Finally I had a look on the Cairo website but was not able to test any
code. Can anyone tell me how to obtain a library for win32 SWT? Do I
have to compile anything first (huaaaaaaaaaaaa) ?
Well, that is my standpoint at the moment. I will be out of office until
next week.
Kind Regards,
Friederich
Ivan Markov wrote:
> What I'm suggesting to Friedrich is to use PostScript/PDF *indirectly*
> through Cairo, because
> - Cairo already has these backends, although still unstalbe
> - org.eclipse.swt.graphics.GC is already wired to Cairo. Shall I explain
> what this means?
> - The pain of doing font subsetting & embedding will be avoided - Cairo
> should do that for Friedrich
--
Friederich Kupzog
Elektronik & Software
Neusser Str. 5-7
50670 Köln
Tel 0241 160696-1
Fax 0221 726670
www.kupzog.de/fkmk
|
|
| | | | | | |
Goto Forum:
Current Time: Thu Sep 26 00:26:27 GMT 2024
Powered by FUDForum. Page generated in 0.10532 seconds
|