Print HTML-Page

Hi, i want to print a HTML-formated Page without the tags and whit pictures in the page, i think thats also called WYSIWYG. How i can do this ? Is there a possiblility to convert HTML to printerfriendly format like RAW ?

maybe you can't got the printer coz your printer didn't support the html flavor like me.
My printer is HP-400 Monochrome. As far I have explore. I just can print txt files :(
There's my code and the error msg.
---my code----
//Example: PrintHTML.java
import java.io.*;
import javax.print.*;
import javax.print.attribute.*;
import javax.print.attribute.standard.*;
import javax.print.event.*;
public class PrintHTML {
     public static void main(String args[]) {
          PrintHTML ps = new PrintHTML();
     public PrintHTML() {
          /* Construct the print request specification.
          * The print data is Postscript which will be
          * supplied as a stream. The media size
          * required is A4, and 2 copies are to be printed
          DocFlavor flavor = DocFlavor.INPUT_STREAM.TEXT_HTML_HOST;
          PrintRequestAttributeSet aset =
               new HashPrintRequestAttributeSet();
          aset.add(MediaSizeName.ISO_A4);
          aset.add(new Copies(2));
          aset.add(Sides.TWO_SIDED_LONG_EDGE);
          aset.add(Finishings.STAPLE);
          /* locate a print service that can handle it */
          PrintService[] pservices = PrintServiceLookup.lookupPrintServices(DocFlavor.INPUT_STREAM.JPEG, null);
          PrintService service = ServiceUI.printDialog(null, 50, 50, pservices, pservices[0], flavor, aset);
          System.out.println("Print Services Located");
          if (pservices.length > 0) {
               System.out.println("selected printer " + pservices[0].getName());
               /* create a print job for the chosen service */
               DocPrintJob pj = pservices[0].createPrintJob();
               System.out.println("Create PrintJob succed");
               try {
                    * Create a Doc object to hold the print data.
                    * Since the data is postscript located in a disk file,
                    * an input stream needs to be obtained
                    * BasicDoc is a useful implementation that will if requested
                    * close the stream when printing is completed.
                    FileInputStream fis = new FileInputStream("test.html");
                    Doc doc = new SimpleDoc(fis, flavor, null);
                    /* print the doc as specified */
                    pj.print(doc, aset);
                    * Do not explicitly call System.exit() when print returns.
                    * Printing can be asynchronous so may be executing in a
                    * separate thread.
                    * If you want to explicitly exit the VM, use a print job
                    * listener to be notified when it is safe to do so.
                    System.out.println("Udh selesai ngeprint.");
               } catch (IOException ie) {
                    System.err.println(ie);
               } catch (PrintException e) {
                    System.err.println(e);
---error messages---
Exception in thread "main" java.lang.IllegalArgumentException: text/html; charse
t="cp1252"; class="java.io.InputStream" is an unsupported flavor
at sun.print.Win32PrintService.getSupportedAttributeValues(Win32PrintSer
vice.java:903)
at sun.print.ServiceDialog$MediaPanel.updateInfo(ServiceDialog.java:1683
at sun.print.ServiceDialog$PageSetupPanel.updateInfo(ServiceDialog.java:
1051)
at sun.print.ServiceDialog.updatePanels(ServiceDialog.java:332)
at sun.print.ServiceDialog.<init>(ServiceDialog.java:149)
at javax.print.ServiceUI.printDialog(ServiceUI.java:161)
at PrintHTML.<init>(PrintHTML.java:34)
at PrintHTML.main(PrintHTML.java:11)

Similar Messages

  • Print Html page Using Java

    I need to print Html Page into my printer, how can I do this. Any help will be appreciated.
    Wil

    File > Print.
    See: http://java.sun.com/javase/6/docs/technotes/guides/jps/spec/printing2d.fm.html
    And:
    http://java.sun.com/j2se/1.4.2/docs/guide/jps/index.html
    And google "Java JPS"

  • Unable to print HTML pages

    After a good bit of reading, I found that printing HTML directly to the printer doesn't work for many printers. I don't want to print the code. I want the actual HTML page. I have some code here that reads the HTML file into a JEditorPane and then is rendered into a graphic for printing.
    My code compiles fine, I'm not getting any errors, but what I'm also not getting is any pages printing.
    Here is the source of my class:
    * PrintReport.java
    * @author tristan
    * Created on September 27, 2007, 4:06 PM
    package fedex;
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.print.PageFormat;
    import java.awt.print.Printable;
    import java.awt.print.PrinterException;
    import java.awt.print.PrinterJob;
    import java.io.*;
    import javax.print.Doc;
    import javax.print.DocFlavor;
    import javax.print.DocPrintJob;
    import javax.print.PrintException;
    import javax.print.PrintService;
    import javax.print.PrintServiceLookup;
    import javax.print.ServiceUI;
    import javax.print.SimpleDoc;
    import javax.print.attribute.*;
    import javax.print.attribute.standard.*;
    import javax.swing.JEditorPane;
    import javax.swing.RepaintManager;
    public class PrintReport
        private FileInputStream fileIS;
        private Doc doc;
        private DocAttributeSet das = new HashDocAttributeSet ();
        PrintService defaultService;
        /** Creates a new instance of PrintReport */
        public PrintReport ()
        public void printHTMLFile (String file) throws FileNotFoundException, IOException
            PrintableEditorPane jEditorPane = new PrintableEditorPane ();
            jEditorPane.setContentType ("text/html");
            jEditorPane.read (new BufferedInputStream (new FileInputStream (file)), "");
            System.out.println (jEditorPane.getText ());
            PrinterJob job = PrinterJob.getPrinterJob ();
            job.setPrintable (jEditorPane);
            if (job.printDialog ())
                try
                    job.print ();
                catch (Exception ex)
                    System.out.println (ex);
        public class PrintableEditorPane extends JEditorPane implements Printable, Serializable
            public int print (Graphics g, PageFormat pf, int pageIndex) throws PrinterException
                Graphics2D g2 = (Graphics2D)g;
                g2.setColor (Color.black);
                RepaintManager.currentManager (this).setDoubleBufferingEnabled (false);
                Dimension d = this.getSize ();
                double panelWidth = d.width;
                double panelHeight = d.height;
                double pageWidth = pf.getImageableWidth ();
                double pageHeight = pf.getImageableHeight ();
                double scale = pageWidth / panelWidth;
                int totalNumPages = (int)Math.ceil (scale * panelHeight / pageHeight);
                System.out.println ("Total pages to print are " + totalNumPages);
                if (pageIndex >= totalNumPages) return Printable.NO_SUCH_PAGE;
                g2.translate (pf.getImageableX (), pf.getImageableY ());
                g2.translate (0f, -pageIndex * pageHeight);
                g2.scale (scale, scale);
                this.paint (g2);
                return Printable.PAGE_EXISTS;
    }I tried using a complex HTML file as well as a basic one, but everytime Total pages to print are 0 is printed back to the console. I can't figure out why it's unable to create any pages to print.

    DrClap wrote:
    I think you will find thatDimension d = this.getSize ();produces (0, 0) until you actually display your component somewhere. I believe it's possible to "display" it in such a way that it doesn't appear on the user's screen, but I don't know how.
    There's a Swing forum here where you get answers from people who are good at Swing. Posting here attracts answers from people like me who are mediocre at it.I think that calling validate() on a Container will lay it out and size it's components, even if it hasn't been made visible, but don't take my word for it.

  • Problem Printing html page with JEditorPane...

    Hello All,
    I Have a problem in printin html file with JEditorPane...
    My Html file contains a Table on it..
    Problem is that JEditorPane displays the html file correctly but
    it prints the file without print that Table..
    So pls help me...
    Thanx in advance,..
    Amit
    [email protected]

    I think you would know how to retrieve content of an HTML page using the URL object. Just in case.
    My apology if this short note doesn't help you at all.

  • Problem in Printing HTML page

    While I am trying to print a HTML page using window.print(), the bgcolor of the table is not printing.

    Did you consider inquiring about this at a Javascript or HTML forum?

  • Printing HTML PAGE in a Applet

    I am tryng to print a HTML Page in a Applet .
    When Using Eclipse Environment everythig goes fine.
    Now I am trying to use the appletviewer to run the same
    source, but it appears the following:
    http://10.15.1.26/
    Conecting to http://10.15.1.26/
    Exception in thread "AWT-EventQueue-2" java.lang.RuntimeException: java.security.AccessControlException: access denied (java.net.SocketPermission 10.15.1.26:80 connect,resolve)
         at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
         at sun.net.www.protocol.http.HttpURLConnection.getHeaderField(Unknown Source)
         at java.net.HttpURLConnection.getResponseCode(Unknown Source)
         at javax.swing.JEditorPane.getStream(Unknown Source)
         at javax.swing.JEditorPane.setPage(Unknown Source)
         at javax.swing.JEditorPane.setPage(Unknown Source)
         at javax.swing.JEditorPane.<init>(Unknown Source)
         at AppletPrintHTML$EditorPaneHTMLViewer.loadStartingPage(AppletPrintHTML.java:90)
         at AppletPrintHTML$EditorPaneHTMLViewer.<init>(AppletPrintHTML.java:103)
         at AppletPrintHTML$5.actionPerformed(AppletPrintHTML.java:364)
         at java.awt.Button.processActionEvent(Unknown Source)
         at java.awt.Button.processEvent(Unknown Source)
         at java.awt.Component.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)
    Caused by: java.security.AccessControlException: access denied (java.net.SocketPermission 10.15.1.26:80 connect,resolve)
         at java.security.AccessControlContext.checkPermission(Unknown Source)
         at java.security.AccessController.checkPermission(Unknown Source)
         at java.lang.SecurityManager.checkPermission(Unknown Source)
         at java.lang.SecurityManager.checkConnect(Unknown Source)
         at sun.net.www.http.HttpClient.openServer(Unknown Source)
         at sun.net.www.http.HttpClient.<init>(Unknown Source)
         at sun.net.www.http.HttpClient.New(Unknown Source)
         at sun.net.www.http.HttpClient.New(Unknown Source)
         at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
         at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
         at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
         at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    Why I am not allowed to connect to the site without Eclipse? Any Idea?
    Angel Portal

    This code
              * Load a HTML Page
              private void loadStartingPage() {
              try {
                   System.out.println("Conectando a "+ path);
                   mainPane = new JEditorPane(path);
                   } catch (IOException e) {
                        System.err.println("N�o Pode Conectar");
                        System.exit(1);
    Open a html page ( path ) on JEditorPane!
    In Eclipse worked just fine!
    But if I try to do that on a Browser or appletviewer the error a told you shows up.
    I am reading about the The Permission Classes.Someone have heard of it?

  • Safari prints HTML page as blank

    When I load an HTML page in Safari and print it, it's totally blank. Doesn't happen in Firefox with the same HTML files.

    Hi John,
    I don't see anything in the console that would be relevant. I'm happy to send you a log if you'd like to see it. (Lots of crap from TextExpander )
    Yes, the thumbnail is blank.
    I should mention I've already tried moving my printer plists to the trash.
    Thanks

  • Printing HTML PAGE

    Java has some Class to handle HTML Pages.
    I want to build a Button that is able to print the
    actual page of the Browser.
    I know about ClipBoard Class, SomeOne has
    some Idea how to do this?
    The idea is to create an applet that creates a button
    to print the actual HTML page.
    Some Idea how to do this, or where I can get this
    information?
    Angel -Portal

    Hello, I got your advise and I could write a small program
    to open a URL ,put it in a JEditorPane like you sad.
    public class EditorPaneHTMLViewer extends JEditorPane implements Printable {
    Inside the code I create a menu to change to portrait to landscape.
    But now I need somehow to print the HTML Page that I took from
    internet.
    I believe that I need to load the content of the JEditorPane to a graphics
    and then set to a Format of a Page and Print, but I do not know how yet.
    Some Hint.
    That true that I could do in a easiest way in JavaScript. But it is going to
    be possible to do landscape and portrait?
    Angel Portal: [email protected]

  • Problems printing html page created from servlet

    Hi
    How do I go about to print a html page that spans outside the visible window (to the left). All I get when I print is the visible page.
    Is it at all possible?
    Would appreciate an answer.
    Thanks
    David Mossberg

    No, not impossible to do.
    You need to provide a printer friendly version of the content so that it spans correctly.
    Again, this is not a Java problem this is an Application problem.
    How you format the data is down to you.

  • Printing html pages from JSF-JSC created pages

    Hi all,
    I have a serious problem with my web apps created with JSC using the JSF components. I designed a page full of tables, developed in vertical for a total of about three or four pages scrolling down.
    When I try to print the generated page from the browser (Firefox, Safari, Explorer) I always get just the first 'page', the entire webpage generated by my application is not saw as a long page, but just 'cutted' out.
    It seems like all JSF components have some problems being like layers or so...any hint? How can I print my html page generated by my web app?
    G

    Perhaps viewing the source of the generated html page will give you a clue to what's wrong..

  • Print JSP/HTML Pages (perhaps PDF?)

    Hi,
    i have a table in HTML generated by JSP.
    Just like the following simple example:
    ...<table>
    <%
    for( Enumeration et = free.getSqlIDs().elements(); et.hasMoreElements();)
    String keyt = (String)et.nextElement();
    Bean b = new Bean();
    b.init(path,DB);
    b.setID(keyt);
    b.restore();
    %>
    <tr>
    <td>
    <%out.print(b.getName());%>
    </td>
    <td>
    <%out.print(b.getAdress());%>
    </td>
    </tr>
    %>
    </table>...
    No i want to give a button to the user. When pressed, the HTML-Page should transform to PDF.
    With such a method i want to print the HTML-Page.
    I Know that this is possible with the help of XML/XSP and a stylesheet. But i like to do that with this way:JavaBeans-->JSP-->HTML-->PDF
    Anyone a solution, some code examples for me?
    Or perhaps another solution to print HTML-Pages in a fine design?
    Thank you for your help
    Andy

    Hi,
    no one any idea?
    How do you print Jsp Pages?
    Thank you
    Bye
    Andy

  • SSRS 2008 R2 report does not print the page header for a html content displaying on multiple pages

    Hi
    I need to display the html content from the database. The html content are quite long and can have content of 3-5 pages. Issue I  am facing is f the record has html content of 3-5 pages, then it does not print the page header (which is a separate tablix) on
    second page onwards.
    Nikesh Shah
    Nikesh Shah

    Hi Nikesh,
    According to your description, I’m not sure the meaning of Page header in your scenario. In Reporting Services, a page header that run along the top of each page, respectively. Headers can contain static text, images, lines, rectangles, borders, background
    color, background images, and expressions. But we couldn’t add tablix in the page header.
    If you are saying report header, a report header consists of the report items that are placed at the top of the report body on the report design surface. They appear only once as the first content in the report. So it cannot repeat in other pages.
    If you are saying tablix header, freezing column headers are different in table and matrix. For more details, please refer to the following thread:
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/c8ddc1af-1bdf-4e72-8aab-0353c7cc848a/ssrs-report-freezing-row-and-column-while-scrolling-issue?forum=sqlreportingservices
    If there are any misunderstanding, please elaborate the issue for further investigation.
    Regards,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Problem with printing multiple Embedded PDF in HTML page

    I have a list of embedded pdf in a html page to be printed in particular order. Using following java script i am trying silently print the pdf one by one. <br /><br />var objectList=document.getElementsByTagName("object");<br /><br />for(i=0;i<objectList.length;i++){<br />   priobj=document.getElementById(objectList[i].id);<br />   priobj.printAll();<br />}<br /><br />Actually the order of call to the printAll methods works correctly.  But the printing of PDF are not is correct order of call. <br /><br />Any Inputs or directions or workarounds on this issue will be really appreciated.<br /><br />Thanks a lot<br /><br />Prem

    HI,
    wat i understand is u r trying to loop at a variable window .but tht is not suggestable.
    write a loop in program lines. read the values in to different variables and the try printing them as text elements that will solve the problem.
    or else in other way use a template and that can also solve the problem.

  • How do I customize my html page in Dreamweaver CS5 to an Avery template that I wish to print out?

    How do I customize my html page in Dreamweaver CS5 to an Avery template that I wish to print out?

    Dreamweaver and websites do not easily match up to Avery templates.  If you are trying to develop a program for customers/etc to print labels, you should look for a script to generate a PDF file to ensure the accuracy of the printing.
    If you are trying to use Dreamweaver as a substitute to print your own labels, I would highly recommend using Microsoft Word, or Adobe InDesign for a better solution.

  • JEditorPane printing a HTML PAGE

    Hi,
    Here is my problem. I am displaying a HTML Page in a JEditorPane. So far so good.
    when I try to print is printing to my printer. Here is the problem the Text or to say the font doesnot look good in the paper, each letter is not nice and smoth and it looks like some of the pixels in each letter were lost. This happens right when I initialize the JEditorPane with html code. I can also see the pixels in each letter are lost when I initilized it in a JEditorPane.
    Any help will be appreciate.

    How are you printing? Are you using the Printing API?
    You can try antialiasing the text before printing:
    http://www.exampledepot.com/egs/java.awt/AntiAlias.html

Maybe you are looking for

  • I'd like to find out how to use the same profile in a dual boot between Win7 and XP Pro.

    Both are at ver. 25.0.1. Win7 is on C: XP Pro is on D: It won't let me add the profile on D: because the profile manager won't allow the : Colin Thank you, Docfxit

  • MacBook Pro Will Not Turn On. Charger light flashing

    Hi there all. I am having a problem with my late 2011 MacBook Pro, and I have tried everything. I was wondering if you might be able to help. I will describe the problem in detail: This morning when I woke up and went to use my macbook, it said the b

  • Songs not showing up in ARTISTS???

    When i go to look for a song i go to ARTISTS..when i do this some of the songs i have on it arent shown in ARTISTS,but when i go to SONGS they are there...whats wrong??? p.s. Its only with some artists not all. Did i organize them wrong when i rename

  • Linked charts: Error bars are not updated

    Linked charts work well: Changed values for bar graph and line graph y values in Numbers are reflected in Keynote and Numbers after "updating". However, I cannot get error bars to be updated as well. They just keep the values they had when I first pa

  • Can some body tell me where my code is going wrong

    I have been trying to print a jTextArea and have been having trouble. Can some body look at my code and tell me where I am going wrong please, Thank You. I have pasted the code below. P.S. I have only attempted to print the jTextArea I have not done