# Printing a document

Karthik Pattabhiraman (pkarthik@wipsys.soft.net)
Wed, 28 Jul 1999 20:00:58 +0530

- Messages sorted by: [ date ][ thread ][ subject ][ author ]
- Next message: Christian M. Forster: "Re: "Java Plug-In Security Warning" dialog working under 1.2.2"
- Previous message: Chris Bradley: "Which encryption method is identical to Unix crypt()"

    From: "Karthik Pattabhiraman" <pkarthik@wipsys.soft.net>

    To: <java-security@web2.javasoft.com>

    Subject: Printing a document

    Date: Wed, 28 Jul 1999 20:00:58 +0530

------=_NextPart_000_0027_01BED933.E89FD160
Content-Type: multipart/alternative; boundary="----=_NextPart_001_0028_01BED933.E89FD160"
X-Sun-Content-Length: 5703

------=_NextPart_001_0028_01BED933.E89FD160
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hello,
I am developing an Internet application using Netscape Application =
Server using Java, JavaScripts and Oracle. I have a unique problem now.
I have implemented the Java Printing API for printing the details =
that I need. This programs works standalone with dummy details. Now, =
when I incorporated this code in the Netscape Application Server which =
is running in NT, I am getting a security exception as follows
****************
java.lang.UnsatisfiedLinkError: doPrivileged doPrivileged
java.lang.UnsatisfiedLinkError: doPrivileged
at java.awt.print.PrinterJob.getPrinterJob(PrinterJob.java:42)
at webtraq.Document.printSetUp(Document.java:298)
at webtraq.Document.setUp(Document.java:272)
at webtraq.Document.processBugDetails(Document.java:214)
at webtraq.Document.execute(Document.java:81)
at com.kivasoft.applogic.AppLogic.execute(AppLogic.java:1201)
at com.kivasoft.applogic.AppLogic.execute(AppLogic.java:1109)
at java.lang.Thread.run(Thread.java:474)
***************
I have a policy file also which is as follows
********
grant {
permission java.security.AllPermission;
};
************
But I am still facing the error. The java program is attached with this =
mail. The setUp method is basically is called from the GUI. When the =
option print is given, then the string one is added to the vector and =
the printing is done and the all option prints all the details that are =
displayed in the GUI. A part of the code is customized to suit my =
requirement. The only problem now is the security.
Can you please help me with this?
Eagerly awaiting a reply from you.
Thanks
karthik

-------------------------------------------------------
P.Karthik
Senior Systems Engineer
e-mail: pkarthik@wipsys.soft.net
ph: (080)8520408 extn:1209.
--------------------------------------------------------

------=_NextPart_001_0028_01BED933.E89FD160
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
Hello,
I am = developing an=20 Internet application using Netscape Application Server using Java, = JavaScripts=20 and Oracle. I have a unique problem now.
I have implemented = the Java=20 Printing API for printing the details that I need. This programs works=20 standalone with dummy details. Now, when I incorporated this code in the = Netscape Application Server which is running in NT, I am getting a = security=20 exception as follows
****************
java.lang.UnsatisfiedLinkError: = doPrivileged doPrivileged
java.lang.UnsatisfiedLinkError:=20 doPrivileged
at=20 java.awt.print.PrinterJob.getPrinterJob(PrinterJob.java:42)
&nbs= p; =20 at webtraq.Document.printSetUp(Document.java:298)
= at=20 webtraq.Document.setUp(Document.java:272)
at=20 webtraq.Document.processBugDetails(Document.java:214)
&nbs= p; at=20 webtraq.Document.execute(Document.java:81)
at=20 com.kivasoft.applogic.AppLogic.execute(AppLogic.java:1201)
= ; =20 at=20 com.kivasoft.applogic.AppLogic.execute(AppLogic.java:1109)
= ; =20 at java.lang.Thread.run(Thread.java:474)
***************
I have a policy file also which = is as=20 follows
********
grant {
permission=20 java.security.AllPermission;
};
************
But I am still facing the = error. The java=20 program is attached with this mail. The setUp method is basically is = called from=20 the GUI. When the option print is given, then the string one is = added to=20 the vector and the printing is done and the all option prints all the = details=20 that are displayed in the GUI. A part of the code is customized to suit = my=20 requirement. The only problem now is the security.
Can you please help me with=20 this?
Eagerly awaiting a reply from=20 you.
Thanks
karthik
-------------------------------------------------------
P= .Karthik
Senior=20 Systems Engineer
e-mail: pkarthik@wipsys.soft.net
= ph:=20 (080)8520408 =20 extn:1209.
--------------------------------------------------------
------=_NextPart_001_0028_01BED933.E89FD160-- ------=_NextPart_000_0027_01BED933.E89FD160 Content-Type: application/octet-stream; name="PrintableImpl.java" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="PrintableImpl.java" X-Sun-Content-Length: 3298 import java.awt.*; import java.awt.print.*; import java.util.Vector; public class PrintableImpl implements Printable { private static Font helveticaBold =3D new = Font("Helvetica-Bold",Font.PLAIN,10); Book book; Paper paper; PageFormat pageformat; int pageIndex =3D 0; Vector v; public int print(Graphics graphics,PageFormat pf , int pageIndex) = throws PrinterException { graphics.setFont(helveticaBold); graphics.setColor(Color.red); String s =3D (String)v.lastElement(); if(s.equals("all")) { int y =3D (int)pf.getImageableY(); int x =3D (int)pf.getImageableX(); System.out.println("Imageablex " +x); y+=3D10; x+=3D10; for(int i =3D 0 ; i < v.size() ; i++) { if(((i%7)=3D=3D0)) { x =3D (int)pf.getImageableX()+10; y +=3D 20; } graphics.drawString((String)v.elementAt(i),x,y); x+=3D((String)v.elementAt(i)).length()+80; } } else if(s.equals("one")) { int y =3D (int)pf.getImageableY(); int x =3D (int)pf.getImageableX(); System.out.println("Imageablex " +x); y+=3D10; x+=3D10; for(int i =3D 0 ; i < v.size() ; i++) { if(((i%2)=3D=3D0)) { x =3D (int)pf.getImageableX()+40; y +=3D 40; } graphics.drawString((String)v.elementAt(i),x,y); x+=3D((String)v.elementAt(i)).length()+200; } } return Printable.PAGE_EXISTS; } public void setUp(Vector v,String str) { this.v =3D v; v.addElement(str); } public void printSetUp(Printable pl) { try { book =3D new Book(); paper =3D new Paper(); paper.setSize(400,400); pageformat =3D new PageFormat(); int pgft=3D0; if(pgft=3D=3D PageFormat.LANDSCAPE) { paper.setImageableArea(15,10,775,540); pageformat.setOrientation(PageFormat.PORTRAIT); } else if (pgft=3D=3D PageFormat.PORTRAIT) { paper.setImageableArea(15,45,540,750); pageformat.setOrientation(PageFormat.PORTRAIT); } //pageformat.setOrientation(PageFormat.PORTRAIT); pageformat.setPaper(paper); book.append(pl,pageformat,1); PrinterJob pj =3D PrinterJob.getPrinterJob(); //pj.printDialog(); pj.setPrintable(pl,pageformat); pj.setPageable(book); System.out.println("Printing .............."); if(pj.printDialog()) { try { pj.print(); } catch(Exception e1) { e1.printStackTrace(); } } else { System.out.println("Printing cancelled"); } } catch(Exception e) { e.printStackTrace(); } } public static void main(String args[]) { PrintableImpl pl =3D new PrintableImpl(); pl.printSetUp(pl); } ------=_NextPart_000_0027_01BED933.E89FD160--

- Next message: Christian M. Forster: "Re: "Java Plug-In Security Warning" dialog working under 1.2.2"
- Previous message: Chris Bradley: "Which encryption method is identical to Unix crypt()"