Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8627001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:09:55+00:00 2026-06-12T08:09:55+00:00

I have print method for html document in my application. I have no access

  • 0

I have print method for html document in my application. I have no access to a physical printer. since I didn’t connect the computer to a physical printer I got the “no printer service found” as specified in code. can I check that function work properly when I connect the computer to a printer without physical printer?

     FileInputStream psStream = null;  
        try {  
            psStream = new FileInputStream("c:\\some.html");  
            } catch (FileNotFoundException ffne) {  
              ffne.printStackTrace();  
            }  
            if (psStream == null) {  
                return;  
            }  
        DocFlavor htmlStreamFlavor = new DocFlavor("text/html; charset=utf-16", "java.io.InputStream");  
        Doc myDoc = new SimpleDoc(psStream, htmlStreamFlavor, null);    
        PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();  
        PrintService[] services = PrintServiceLookup.lookupPrintServices(htmlStreamFlavor, aset);  

        // if several printers configured  
        PrintService myPrinter = null;  
        for (int i = 0; i < services.length; i++){ 
            String svcName = services[i].toString(); 
            System.out.println("service found: "+svcName);              
            if (svcName.contains("printer closest to me")){  
                myPrinter = services[i];  
                System.out.println("my printer found: "+svcName);  
                break;  
            }  
        }  

        if (myPrinter != null) {              
            DocPrintJob job = (DocPrintJob) myPrinter.createPrintJob();  
            try {  
            job.print(myDoc, aset);  

            } catch (Exception pe) {pe.printStackTrace();}  
        } else {  
            System.out.println("no printer services found");  
        }  
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T08:09:56+00:00Added an answer on June 12, 2026 at 8:09 am

    There are logical printers that create a pdf instead of printing. For your application they look just like a normal printer.

    See this rather long list for options: https://www.google.de/search?q=pdf+printer

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a generic Print method that iterates over a list and simply prints
i have override validate method and added errors using addFieldError(test, test print); and in
I have a web service to which I send a xml request (application/x-www-form-urlencoded encoded)
I have a simple button in HTML like this: <input type='button' id='btnPrint' value='Print' onclick=changeStylesheet();
i have this files: JAVASCRIPT $(document).ready(function(){ $('a').click(function(){ $('div').load(formular.html,function(){ $('input[type=submit]').click(function(){ $('form').submit(); }); }); }); });
I have created a simple applet and HTML document, but when I open the
I wish to print a document by passing custom html code. The non-working code
I'm trying to open an external HTML document in LWUIT, but I have an
I have a method which calls a method on an integer: def print_time(time =
i have bug that i cannot find, i have Class Point with method who

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.