Results 1 to 2 of 2
  1. #1
    Alan is offline Member
    Join Date
    May 2007
    Posts
    39
    Rep Power
    0

    Default print .doc in java

    Hello guys
    I have to print documents using java
    I have looking awt.print lib but it is to print text not document. doc

    Can you help me?
    IŽll appreciate that

  2. #2
    Freddie is offline Member
    Join Date
    May 2007
    Posts
    41
    Rep Power
    0

    Default

    Try this:

    Java 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);//destFileNamePdf es el archivo a imprimir 
          
          Doc doc = new SimpleDoc(fis,flavor,das); 
         try {
       job.print(doc,null);
       
        } catch (PrintException e) { 
       
       e.printStackTrace();
      }
         } catch (FileNotFoundException e) {
      e.printStackTrace();
         }
    Last edited by levent; 05-17-2007 at 09:11 AM. Reason: Code is placed inside [code] blocks.

Similar Threads

  1. How to print text file in java(dotmatrix printer)
    By yoganeethi in forum Advanced Java
    Replies: 4
    Last Post: 12-01-2010, 02:45 PM
  2. Print XML tag
    By DonCash in forum XML
    Replies: 2
    Last Post: 08-07-2007, 07:02 PM
  3. print in java linux
    By bbq in forum Advanced Java
    Replies: 1
    Last Post: 07-05-2007, 05:24 AM
  4. Print A Pdf
    By Jack in forum Advanced Java
    Replies: 2
    Last Post: 07-02-2007, 06:40 AM
  5. Java Print Dialog Framework 1.7
    By levent in forum Java Software
    Replies: 0
    Last Post: 06-19-2007, 06:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •