🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.api
Article #915

J2SDK4 printing - How to set margins

#915
From: Johan Forsberg
Date: Wed, 03 Jul 2002 18:51
51 lines
3193 bytes
A client wants a html2ps filter to run on Linux boxen. Undoable just
recently, but now we have a version of Java (1.4) that can

1) Run (some) graphical applications headless.
2) Has a so-so HTML component.
3) Can print any components to PS, thanks to the new javax.print API.

Unfortunately, I'm having some problems with both 1), 2) and 3). :-)

1) Yes, I can run the app headless. But on a platform that has a 'head' the
goddamn windows will still pop up. Is there any way to indicate that you
DONT WANT ANY WINDOWS, ie RUN AS HEADLESS even if you have a graphical
environment. Minor point, the other two are much more important.

2) SUN's JEditorPane can, sort of, display HTML. It handles CSS very badly,
and my clients write lots of *really bad* html and CSS. It looks great in IE
so why can't I get it right? *Sigh* I found a commercial html component
(NetClue) that seems to be a-ok and not to expensive. I'll use that unless
anyone pipes up and points me to a better, freer html component...

3) Load, layout, print. It works great but for one thing: I must be using
the new javax.print PrintAttributeSet wrong. I create, and use my
PrintAttributeSet like this:

   StreamPrintService sps = factories[0].getPrintService(fos);

   DocPrintJob pj = sps.createPrintJob();
   PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
   // Gray scale only, this is for faxes after all
   aset.add(Chromaticity.MONOCHROME);
   // Try to set correct paper and reasonable margins.
   // A4=210x297 mm. 1 cm margins
   aset.add(MediaSizeName.ISO_A4);
   aset.add(new MediaPrintableArea(10, 10, 190, 277,
MediaPrintableArea.MM));

   Printable p=new ComponentPrintable(c); // Mine, for printing Components.
   Doc doc = new SimpleDoc(p, flavor, null);

   pj.print(doc, aset); // WHY doesn't it use my Attributes?

However, none of the things I add to the AttributeSet seem to make any
difference.
I still get color, 1" margin printouts. What gives?


--
<--/---\------76-cols-----------------^-----Your-Name-Here----Something---->
 / Small*<-Perth  Make Your Very   4 rows email@address.here witty some
/  Ascii  \     Own Signature File!   |    Profession Here    dead guy
\ Picture /   Follow The Instructions v  Other Personal Info  said here
Technical Details
Message-ID: <3d2417d2$2_1@dnews>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!supernews.com!yellow.newsread.com!netaxs.com!newsread.com!west.cox.net!cox.net!newsfeed.media.kyoto-u.ac.jp!newsfeed01.tsnz.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1089d0,f8be8c29d1ec9918
X-Google-Attributes: gid1089d0,public
X-Google-ArrivalTime: 2002-07-04 02:52:45 PST
From: "Johan Forsberg" <firstname@lastname.pp.se>
Newsgroups: borland.public.jbuilder.java.api
Subject: J2SDK4 printing - How to set margins
Date: Wed, 3 Jul 2002 20:51:40 +0200
Lines: 53
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
NNTP-Posting-Host: 130.78.143.1
Message-ID: <3d2417d2$2_1@dnews>
X-Trace: dnews 1025775570 130.78.143.1 (4 Jul 2002 02:39:30 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!supernews.com!yellow.newsread.com!netaxs.com!newsread.com!west.cox.net!cox.net!newsfeed.media.kyoto-u.ac.jp!newsfeed01.tsnz.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews