Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-14-2007, 06:25 PM
Senior Member
 
Join Date: Jun 2007
Posts: 130
Jack is on a distinguished road
Print A Pdf
I'm trying to print pfd from java application
this is the code:
Code:
DocFlavor flavor = DocFlavor.INPUT_STREAM.PDF; PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); aset.add(MediaSizeName.ISO_A4); aset.add(new Copies(1)); PrintService service = PrintServiceLookup.lookupDefaultPrintService(); DocPrintJob printJob = service.createPrintJob(); Doc doc = new SimpleDoc(filePDF,flavor,null) try { printJob.print(doc, aset); } catch (PrintException e) { e.printStackTrace(); }
but it doesn't work, can you help me?
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-02-2007, 07:38 AM
Senior Member
 
Join Date: Jun 2007
Posts: 119
Peter is on a distinguished road
I think that the api of sun isn't possible to print a pdf document directly.
(only txt)
If you have the openoffice installed, you can invoke to the print order directly from runtime
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-02-2007, 07:40 AM
Ed Ed is offline
Senior Member
 
Join Date: Jun 2007
Posts: 110
Ed is on a distinguished road
Hi jack, try this:
Code:
import java.awt.print.*; import java.util.*; import javax.print.*; import javax.print.attribute.*; DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE; PrintService service = PrintServiceLookup.lookupDefaultPrintService(); if (service != null) { try { DocPrintJob job = service.createPrintJob(); DocAttributeSet das = new HashDocAttributeSet(); FileInputStream fis = new FileInputStream(destFileNamePdf); Doc doc = new SimpleDoc(fis,flavor,das); try { job.print(doc,null);
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
print line kazitula Java Applets 2 01-26-2008 04:05 PM
Print Area Riftwalker Advanced Java 0 11-28-2007 09:28 PM
Print XML tag DonCash XML 2 08-07-2007 08:02 PM
doubt about PRINT API valery New To Java 1 08-06-2007 11:51 PM
print .doc in java Alan Advanced Java 1 05-17-2007 06:05 AM


All times are GMT +3. The time now is 12:09 PM.


VBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org