Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

null pointer at DocPrintJob print

 
osiruz
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi...

Im getting this error on my DocPrintJob.print()

---------
java.lang.NullPointerException
at sun.print.Win32PrintJob.initializeAttributeSets(Unknown Source)
at sun.print.Win32PrintJob.print(Unknown Source)
at com.finantix.applet.PrintApplet.print(PrintApplet.java:72)
at com.finantix.applet.PrintApplet.start(PrintApplet.java:45)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
-----
can anyone help? I'm not sure what is wrong cos i'm pretty sure all the values are set and nothing is null. Pls. advise.

Thanks!

p/s:

here's a snippet my applet code


service = PrintServiceLookup.lookupDefaultPrintService();
myFormat = javax.print.DocFlavor.INPUT_STREAM.AUTOSENSE;
initPrintTags();
System.out.println(text);
text = formatText(text);

System.out.println("Testing ::: "+text);

java.io.InputStream sr = new ByteArrayInputStream(text.getBytes());

System.out.println("2 ::: "+sr);

DocPrintJob pj = service.createPrintJob();

System.out.println("3 ::: "+pj);

javax.print.Doc myDoc = new SimpleDoc(sr, myFormat, null);

System.out.println("4 ::: "+myDoc);

try
{
System.out.println("PJ:"+pj);
System.out.println("MyDoc:"+myDoc);
pj.print(myDoc, null);
System.out.println("---"+myDoc);
}

---------------

all the System.out.println does not report any null, except the one after "pj.print(myDoc,null);" which never gets printed. The null pointer exception was thrown at that line.
 
osiruz
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i found the problem.
its due to the jar file not signed.
after it's signed...im now able to access the print command
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello "osiruz"-

Welcome to JavaRanch.

On your way in you may have missed that there is a policy on screen names here, and that yours does not conform to it. We take this policy seriously, so please change it accordingly, which you can do right here.

Enjoy your time here at JavaRanch.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic