How to print a HTML file in browser look using DocPrintJob

Hello guys,
Does anyone know how to print HTML output/file into browser look?
I'm using DocPrintJob and the DocFlavor set to DocFlavor.INPUT_STREAM.AUTOSENSE.
posted below is my code :
public class BasicPrint {
    public static void main(String[] args) {
        try {
            // Open the image file
            String testData = "C:/new_page_1.html";
            InputStream is = new BufferedInputStream(new FileInputStream(testData));
            DocFlavor flavor =  DocFlavor.INPUT_STREAM.AUTOSENSE;
            // Find the default service
            PrintService service = PrintServiceLookup.lookupDefaultPrintService();
            System.out.println(service);
            // Create the print job
            DocPrintJob job = service.createPrintJob();
            Doc doc= new SimpleDoc(is, flavor, null);
            // Monitor print job events; for the implementation of PrintJobWatcher,
            // see e702 Determining When a Print Job Has Finished
            PrintJobWatcher pjDone = new PrintJobWatcher(job);
            // Print it
            job.print(doc, null);
            // Wait for the print job to be done
            pjDone.waitForDone();
            // It is now safe to close the input stream
            is.close();
        } catch (PrintException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
    static class PrintJobWatcher {
        // true iff it is safe to close the print job's input stream
        boolean done = false;
        PrintJobWatcher(DocPrintJob job) {
            // Add a listener to the print job
            job.addPrintJobListener(new PrintJobAdapter() {
                public void printJobCanceled(PrintJobEvent pje) {
                    allDone();
                public void printJobCompleted(PrintJobEvent pje) {
                    allDone();
                public void printJobFailed(PrintJobEvent pje) {
                    allDone();
                public void printJobNoMoreEvents(PrintJobEvent pje) {
                    allDone();
                void allDone() {
                    synchronized (PrintJobWatcher.this) {
                        done = true;
                        PrintJobWatcher.this.notify();
        public synchronized void waitForDone() {
            try {
                while (!done) {
                    wait();
            } catch (InterruptedException e) {
}the printed ouput for this code will be look like this
<html>
<body>
<div style="page-break-after:'always';
            background-color:#EEEEEE;
            width:400;
            height:70">
     testPrint</div>
ABCDEFGHIJK<p>
 </p>
</body>
</html>however, the output that i want is the HTML in browser look not HTML code itself.
i've tried to change the DocFlavor into any TEXT_HTML type but it gives error:
sun.print.PrintJobFlavorException: invalid flavor if you guys has any idea or solution, can you share with me... already search in Google but still not found any solution
Thanks in advanced.

hi,
do the following
URL url = null;
try
     url = new URL("http://www.xyz.com");
catch (MalformedURLException e)
      System.out.println("URL not correct " + e.toString());
if (url != null)
       getAppletContext().showDocument(url,"_blank"); //shows the page in a new unnamed top level browser instance.
}hope that helpz
cheerz
ynkrish

Similar Messages

  • How to load an html file in Text Box using script?

    Hi,
    does anyone know what is the sequence of commands for inserting an html file in a text object, if possible, via vbs?
    Unfortunately, I wasn't able to find the Commands and Variables for the text object (aka user object) in the help. Where I can search for them?
    Thank you!

    Hi def90,
    Sorry for the confusion. In that point the help information is not correct. We can only import RTF and ASCII via script but not HTML. We are going to change the help for that.
    Greetings
    Walter

  • How can i get rid of the print dialog box when using api to print an html file

    i am using the systemshell.vi provided by labview the VI is working fine but it will open a dialog box for printer selection and properties. i would like to hide that dialog box and have it print to the default printer with the default properties

    ShellExec is part of lvwutil and merely calls a function in Shell32.dll. There is nothing about the function call that controls the display of the printer dialog. I think that what shell32.dll does when it prints (just like right clicking on the file) is print the file according to what is defined about that file type in Windows Folder Options. On my Win2K system, the print application is defined as "C:\Program Files\Microsoft Office\Office\msohtmed.exe" /p %1. If I remove the /p, then Word starts up and in order to print, I get a printer dialog when choosing Print from the File menu. So it seems like the printer dialog is entirely dependant on the application that does the printing. I get no dialog when I use the VI to print a .txt file. I
    nstead of using shell32, you might want to try some ActiveX method or property of an application like Internet Explorer that can open and print an html file.

  • How to print/store in file the ref cursor in pl/sql block ?

    How to print/store in file the ref cursor in pl/sql block ?.

    How to print/store in file the ref cursor in pl/sql block ?.You question is quite confusing?
    So, i'm providing link in this manner.
    For RefCursor,
    http://www.oracle-base.com/articles/misc/UsingRefCursorsToReturnRecordsets.php
    http://www.oracle.com/technology/oramag/code/tips2003/042003.html
    For UTL_FILE,
    http://www.morganslibrary.org/reference/utl_file.html
    Regards.
    Satyaki De.
    Updated with new morgan library link.
    Edited by: Satyaki_De on Feb 24, 2010 9:03 PM

  • How to print a PDF file that was display in my page...

    Hi !. My doubt would be the following one... I would like to know how to print a pdf file that was displayed in my page ?... I mean the PDF file not the page...
    The PDF would be in this url:
    http://iprodesa.lasegunda.com.ar:8090/datos/pdf/830.pdf
    How could I implement this ?...

    This first question which comes to mind is how do you display the pdf file in the browser?
    For this the browser uses a plug in (e.g. adobe reader) which already has the ability to print the pdf file. Depending on the version of your plug in, printing is started differently.
    Timo
    Ps: which jdev version do you use?

  • How to call a html file in a java file

    how to call a html file inside a java file ?

    Hopeless. Are you by any chance a rare gas? You seem completely inert. LOL You totally pwned him there :rolls eyes:
    well, no, I think he's looking for something to this degree:
    in HTML, there is a mailto: command that makes the system default handled way to email emails open up. He's looking for a command thats very nice and opens a html file in the system default browser.
    So, Dick, Runtime.exec would work execpt that he needs a way to find the default system browser to call exec on, AND he has to know how to pass html file locations to the executable via command line arguments
    He just didnt try to phrase it at all :P

  • How to Parse an HTML File?

    Hi all
    I want to parse an HTML file?
    How is it possible?
    After taking an input which is an HTML file, i need to parse it, and i need to print/modify values based on some tags?
    Please help me, how to parse an HTML file?

    You start by reading the first character and then continiung until you reach the last character.
    For a more serious answer try elaborating on your question. Its really really vague.

  • How to add a html file into JEditorPane

    Hi
    I am doing an aplication on swing.But I don't know how to add a html file to the JeditorPane keeping the html file on the source code. i.e my html file is in my source code.Then how to add this html file to Jeditor pane.
    Thanks
    Srikant

    QuickTime requires player and plugins that most people don't have.  You'll reach a much wider audience if you use HTML5 <video> with mp4, webm and ogg files.
    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>HTML5 with Video</title>
    <!--help for older IE browsers-->
    <!--[if lt IE 9]>
    <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    </head>
    <style>
    video {
        max-width:100%;
        display:block;
        margin:0 auto;
    </style>
    <body>
    <h2>Use 3 File Types to support all browsers &amp; mobile devices:  MP4, WEBM and OGV.</h2>
    <h3>Online Video Converter
    http://video.online-convert.com/</h3>
    <!--begin video-->
    <video controls poster="Your_poster_image.jpg">
    <!--these are 6 sec sample videos for testing purposes. Replace sample-videos with your own files-->
    <source src="http://techslides.com/demos/sample-videos/small.webm" type="video/webm">
    <source src="http://techslides.com/demos/sample-videos/small.ogv" type="video/ogg">
    <source src="http://techslides.com/demos/sample-videos/small.mp4" type="video/mp4">
    If you're seeing this, you're using an
    outdated browser that doesn't support
    the video tag. </video>
    <!--end video-->
    </body>
    </html>
    Nancy O.

  • How to print a pdf file from Labview

    Hi,
    Does anyone know how to print a pdf file form Labview. I need to be able to point on the pdf file and to print it.
    Activex examples doesnt seem to be working it always displays an error, on every PC that I tryed to run it.
    {"code 3005" ,,,"Automation Open: Object specified is not creatable in Display PDF in Dialog.vi"}.
    Thank you for your help.
    Regards,
    Jenia.

    You can use the "System Exec.vi". The command line should have the following structure:
    "<Path to AcroRd32.exe>" /t "<Path to document>" "Printer name"
    For example"
    "C:\Program Files\Adobe\Acrobat 5.0\Reader\AcroRd32.exe" /t "C:\myreport.pdf" "Tektronix Phaser 300i"
    Regards;
    Enrique
    www.vartortech.com

  • How to print a pdf file of compounds A3 and A4 with adobe mac

    how to print a pdf file of compounds A3 and A4 with adobe mac, windows with the option I choose paper source by PDF page size mac but I can not find it. how to get it thank you

    I think if you use the start-command, the execution is asynchronously and you won't get the correct process-id. Try to execute Acorbat directly without the cmd /c start in front of it.

  • How to put an HTML file into JEditorPane

    Hi
    I am doing an aplication on swing.But I don't know how to add a html file to the JeditorPane keeping the html file on the source code. i.e my html file is in my source code.Then how to add this source code to Jeditor pane.
    Thanks
    Srikant

    hi srikkant,
    ur html code is inside the source code..? are you working on applets..? if ur html file can be read as a file and the file stream can converted to a string and put into a Jeditor pane using the setText() method. for editing HTML text a editor called javax.swing.text.html.HTMLEditorKit can be used.
    Refer to JAVA API for further clarifiactions and examples.

  • Can AnyOne Please Tellme How to configure the HTML files

    This is very Urgent.
    1.I am using the WLS7.0 sp1 .I need to configure theHTML files which are in a
    different path how can I map them to the present DefaultWebAPP directory.
    2. How can I get rid of the port number when I am fully using in production mode.
    I have been posting this query since long but in vain. Please guide me

    1. I got rid of port number with link provided by the karthik.
    2.How can I create a link .The link appends to the defaultwebapp directory
    and checks from their .I need to know how to configure the
    HTML files which are not in the DefaultWebApp.But completely in directory.
    Any suggestions !!!!!!!
    Shehzad <[email protected]> wrote:
    1. You can create a link to that directory
    2. In order to get rid of port number, either boot weblogic at default
    port 80, or use Apache or Iplanet webserver, and use Weblogic plugin.
    That way all the traffic comming in from http will comein at port 80
    to the webserver, and would then be forwarded to Weblogic at whatever
    port it is booted.
    This is very Urgent.
    1.I am using the WLS7.0 sp1 .I need to configure theHTML files whichare in a
    different path how can I map them to the present DefaultWebAPP directory.
    2. How can I get rid of the port number when I am fully using in productionmode.
    I have been posting this query since long but in vain. Please guideme

  • How to embed the html file into form 6i?

    How to embed the html file into form. What control activeX should i use? please help!!!!!!

    You can use web.show_document function for this purpose. See
    form builder help topics for more details.
    Hope this helps.

  • Problem printing PDF picture files imported from JPG using HP Colour InkJet cp1700 printer

    When I print PDF picture files imported from JPG using an HP Colour InkJet cp1700 printer, the picture spills over.  A wide range of other PDF files print OK.  Have tried things such as configuring the printer to scale to letter size, etc,, but without success.  Have a Windows 7 64 bit computer and Adobe Acrobat Pro Extended 9.5.5.  Any ideas?

    Hello there! Welcome to the forums @rt70 
    I understand you're having some issues with printing PDF files from a website on Windows 7.
    I would personally suggest trying to print from that website using a different web browser. If you're using Internet Explorer, try FireFox or Chrome, for example.
    You can also try running the Print and Scan Doctor tool, that will search and try and fix printing issues.
    If you have any issues that continue, please let me know what they are and which programs, websites, and web browsers you have tried, along with the results from running the diagnostic tool above.
    Good luck and have a great day
    R a i n b o w 7000I work on behalf of HP
    Click the “Kudos Thumbs Up" at the bottom of this post to say
    “Thanks” for helping!
    Click “Accept as Solution” if you feel my post solved your issue, it will help others find the solution!

  • How to load a client file in a clob using sqlcl

    How to load a client file in a clob using sqlcl

    You don't "load" jars. If it's on the classpath, you can obtain individual resources from it using various methods on either Class or ClassLoader. Do you mean "how to add a jar to the classpath at runtime"? Can't be done without using a classloader, typically URLClassLoader or a subclass thereof. Why you want to not use the proven method is beyond me. Presumably because you don't understand classloading. In which case, forget it.

Maybe you are looking for

  • Deploy Adobe Creative Cloud Issue

    Hi,  I am creating application of Adobe Creative Cloud in SCCM 2012 R2. In the User Experience I selected "Install for System" like other applications. When I install it from Software Center, Software Center closes itself in the end of installation (

  • Quorum/Witness Disk Offline every 15 minutes error - Event ID 1069 - Event ID 1558

    2 node active passive, 2008 failover cluster.  I keep getting the following error events: The cluster service detected a problem with the witness resource. The witness resource will be failed over to another node within the cluster in an attempt to r

  • Trouble with order of select list values

    Ok my list of values def is:<br> <br>select distinct SOFTWARE d,<br> SOFTWARE r<br> from DBA_SW_INVENTORY<br> <br>The problem is that values are displayed like so:<br> A<br> B<br> C<br> D<br> b<br> d<br><br> I would like to see<br> A<br> B<br> b<br>

  • "select into" query statements using the DI API

    I am trying to use the DI API (6.5) t create a temp table based on an existing table.  For example, here is a query string.... select * into ORDR_TEMP from ORDR Code... oRecordSet := IRecordset(oCompany.GetBusinessObject(BoRecordset)); oRecordset.DoQ

  • Missing Add DHCP Reservations Option

    I have an older Airport Extreme Base Station (flying saucer variety...version 5.7...purchased approx. 2005(?) 802.11b/g).  I am using an iMac with AirPort Utility 5.5.3.  I am attempting to set up my AEBS to allow Remote Management from my MacBook Pr