Print HTML File Without Showing on Screen

Hi Everyone
Is there a way to print a file (in particular, an html file) from a java app without actually displaying the file on the screen.
ie. print from command line.
I am creating an html file from within java app and would like to print it in one step.
Any help would be greatly appreciated.
Thanks
Kelly

Hi,
Heres some code from an app I wrote that prints out text. I've stripped out little sensitive bits.
// Procedure to perform when print button is pressed
   void printButton_actionPerformed(ActionEvent e){
     int x, y, pageNo = 1, maxPageHeight, textHeight = 0;
     Date today = new Date();
     String tempLine = new String("");
     String tempString = new String();
     Graphics pg;
// Create date and time formats
     SimpleDateFormat dateFormatter = new SimpleDateFormat("dd/MM/yy");
     SimpleDateFormat timeFormatter = new SimpleDateFormat("HH:mm:ss");
// Create date and time strings
     currentDate = dateFormatter.format(today);
     currentTime = timeFormatter.format(today);
// Turn off double buffering
     RepaintManager.currentManager(this).setDoubleBufferingEnabled(false);
// Get a print job
     PrintJob printjob = getToolkit().getPrintJob(this, "<printjob name>", null);
     if (printjob != null) {
       maxPageHeight = printjob.getPageDimension().height-(rowHeight*2);
       pg = printjob.getGraphics();
       if (pg != null) {
         pg.setColor(Color.black);
         pg.setFont(new Font("Courier", 0, 10));
// Print header
         textHeight = topOfPage;
         pg.drawString("Report      Date " + currentDate +
                       "      Time " + currentTime + "  Page " + pageNo,
                       30, textHeight);
         textHeight += rowHeight;
         pg.drawString("File: " + dataFile , 30, textHeight);
// Print errors
         textHeight += rowHeight*2;
         pg.drawString("Errors", 30, textHeight);
         textHeight += rowHeight;
         pg.drawString("------", 30, textHeight);
         textHeight += rowHeight;
         pg.drawString("col1         col2 col3                 Value        Reason",
                        30, textHeight);
         textHeight += rowHeight;
         pg.drawString("------------ ---- -------------------- ------------ --------------------",
                        30, textHeight);
         if(errorData != null){
           for(x = 0; x < errorData.length; x++){
             textHeight += rowHeight;
             if(textHeight > maxPageHeight){
               pg = nextPage(pg, printjob, ++pageNo);
               textHeight = topOfPage + rowHeight*2;
             tempLine = "";
             for(y=0; y<columnLengths.length; y++){
               tempString = errorData[x][y] != null ?
                            roundLength(errorData[x][y].toString(), columnLengths[y])
                            : roundLength(" ", columnLengths[y]);
               tempLine += tempString + " ";
             pg.drawString(tempLine, 30, textHeight);
         pg.dispose(); // flush page
       printjob.end();
   }Hope that helps.
Rob.

Similar Messages

  • Print html file without seeing a print dialog box

    i need to script an action that would allow a user to print a sparcly formated html file to a printer while bypassing the normal print dialog box.
    the unix lpr command seems like it might work, but the man page only mentions PS and txt files.
    Ultimately i'd want to trigger the print action from a php script, but it could be a folder action also.
    Does anyone have any suggestions or point me in the right direction.

    lp is the right command to use but you may need to convert the html file in PDF format before printing it. Just test it. Also type man lp to see more options.
    enscript is a nice utility that may help you. man enscript for more.
    Mihalis.

  • After changing my graphic card to an ASUS Strix GT 970, Photoshop CS6 opens the JPG files without show them on the screen

    After changing my graphic card to an ASUS Strix GT 970, Photoshop opens the JPG files without show them on the screen

    Try turning off GPU support in your Photoshop's preferences performance section.  Also check that you have installed the latest device driver installed for your GT 970 adapter and that all CS6 updates are installed... Your CS6 should be version 13.0.1.3....

  • Print html file via share intent

    Hello HP
    I'm a developer, I trying to print html file to HP Printer via share intent. Here is my code:
    Intent intent = new Intent("org.androidprinting.intent.action.PRINT");
    Uri uri = Uri.parse(path);
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.setDataAndType(uri, "ePrintWebContent/*");
    startActivity(intent);
    Nothing happen when I share this intent. Please show me right way to print html file.
    Thank you!!

    Did you look in the LabVIEW Help? http://zone.ni.com/reference/en-XX/help/371361G-01​/lvhowto/reg_hndl_ax_evnts/
    You right-click on that parameter and select Create Callback VI. This will automatically create a VI with the required inputs and outputs. This is the VI that will be called when the event occurs. If you need the callback VI to update any front panel controls of the main VI, then you can pass in control references via the User Parameter input.
    Attached is a modification of the shipping example that handles the Navigate and DocumentComplete events.
    Attachments:
    Navigate Callback Example.vi ‏24 KB
    Navigate Callback.vi ‏15 KB
    DocumentComplete Callback.vi ‏15 KB

  • Can I print a calander without showing the times of events?

    Can I print a calander without showing the times of events. Or, alternatively, is there a way to list things without having them be an event. Just notes on the day, for instance.

    It seems like a simple solution must be at hand. There is an option in the iCal Preferences (General) panel--Show event times. With this command unchecked the screen view of the month view is free of the times of day, but when I print the month view the times of day are printed.

  • Print html file with barcode from abap report

    hi
    i am printing html file from abap program using gui_execute.
    i am using netscape.exe , its printing first time and when reprint its not working
    basically html file contains gif file which has fedex barcode.
    could you please let me know how to print html file from report

    DGU wrote:
    where to check RAW or TEXT? the print report vi only asks for file name and printer name.
    When I print from notepad, everything just goes by default. This is a label printer, so I never need to specify printing parameter such as size, orientation, etc in the past
    Famous last words go something like this: "...never had to do that before."  Maybe you have to do that now.  It's worth at least comparing the defaults settings for bothe generic drivers.  It could save you a lot of headache if you notice something different.
    Bill
    (Mid-Level minion.)
    My support system ensures that I don't look totally incompetent.
    Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.

  • How do I save a pdf as an html file without losing formatting?

    How do I save a pdf as an html file without losing formatting?  My coworker is able to do this on her Adobe 9 by saving to html css 4.0 - I have Adobe 11 and have not been able to save as an html at all without loosing formatting.

    Are the PDF files that you are attempting to Save As HTML tagged?

  • How to display a html file without tags?

    Hello,
    I am new for Java programming. Now i have to display a html file without all the tags. My code is the fllowing:
    u = new URL("http://www.ncbi.nlm.nih.gov/entrez/viewer.fcgi?db=protein&val=55584070");
    BufferedReader in = new BufferedReader(new InputStreamReader(u.openStream()));
    while ((s = in.readLine()) != null) {
    System.out.println(s);
    in.close();
    Unforturnately, the output is the soucecode of the html file and I just want the content.
    Please help me.
    Thanks a lot in advance,
    Danica

    Here's a simple example
    http://forum.java.sun.com/thread.jspa?threadID=293830
    I haven't tested it, but I bet camickr did.

  • Embed  html file without using IFrame UI

    Is there any way to embed html file without using IFrame UI?

    Hi
    To embed a static HTML content inside your view, Iframe is the easiest form or else, you can provide links through Linktourl UI or through a static text or a button, invoke a action and display the HTML content inside the frame or call it in a seperate (external) window.
    Otherwise, we have only less options!
    if you have anything specific, do let us know
    thanks
    sathya

  • Print pdf files without open them

    i am using gnome and adobe reader to open pdf file. however, is there anyway i can print the files without open them ?

    lpr somefile.pdf - as long as cups is configured correctly.

  • Please wait. printer preperation occurring. keeps showing on screen

    if i hook up with usb i can print but "please wait. printer preperation occurring". keeps showing on screen can anybody help me?

    Please read this post then provide some details.  What printer model? What operating system? 
    Bob Headrick,  HP Expert
    I am not an employee of HP, I am a volunteer posting here on my own time.
    If your problem is solved please click the "Accept as Solution" button ------------V
    If my answer was helpful please click the "Thumbs Up" to say "Thank You"--V

  • How print .html file?

    Hi,
    I'm a beginner printing in Java.
    What I'm trying to do is to print .html file but I don't know how to do it well.
    Please, someone who can help me to solve this problem.
    Thanks a lot!

    i have the same problem, hope some1 could help.
    cheers.

  • Printting HTML file...

    Hi all,
    anybody knows that how to print HTML file. i mean the contents which are viewable in browser.
    please let me know..
    Thanks in advance..

    check this out
    http://java.sun.com/printing/whitepaper.html

  • Importing new bookmark html file without doubling bookmarks

    I saved my bookmarks form my laptop in an html file. now I want to import that file into the bookmarks on Firefox on my netbook.
    the files are basically the same but i have dded several new bookmarks because I was using my laptop and have not used my netbook in awhile.
    how do I import the new html file without doubling the bookmarks that are already on my firefox which is running on my netbook. a lot of the folders are the same.

    There is no option to just import the new bookmarks.
    A few options.
    # Import the HTML file, then use the CheckPlaces extension to remove the duplicates - https://addons.mozilla.org/firefox/addon/checkplaces
    # Use the Firefox Sync extension to synchronize the bookmarks - https://addons.mozilla.org/firefox/addon/firefox-sync
    # If you want bookmarks on the netbook to be replaced with those from the laptop used the method in the following link - https://support.mozilla.com/kb/Backing+up+and+restoring+bookmarks
    With the last method, you backup the bookmarks to a json file and import that file onto the netbook. When you restore a json file on the other computer it will remove all bookmarks that currently exist and replace them with those in the json file.

  • Print report from client machine without showing in screen

    Hi guys!!
    I m using (forms10g+ 10gAS). I want to Print report from client machine without showing in the screen/monitor.
    Currently I m generating report in pdf format. From the pdf I m printing the document.
    But my requirements is to print directly to the printer without showing preview
    Thanks in advance
    Mokarem

    Maybe this will help:
    http://forums.oracle.com/forums/thread.jspa?messageID=1209371&#1209371
    Gary

Maybe you are looking for

  • How Can I Use Bluetooth For Sharing With iPhones?

    Hello, i have an iPod touch 3rd Gen. 32GB, And I'm Wondering How Could I Share Music or Photos With My Cousin's iPhone (Jailbroken iPhone), When I Turn The Bluetooth On, Nothing Shows Up On My iPod Or On Here iPhone, So How Could I Share Things With

  • Is it possible to circumvent read-only after a pdf has been signed?

    Hi, my pdf has a signature field.  In the signed event I have make all fields read-only.  Is it possible for someone to come along and make them not read-only anymore?  It seems the easiest way to make my document tamper-proof.  Thank you.

  • Laptop boots up but display is intermittent

    laptop boots ok and display is available on external monitor or hdmi to tv. lap top display backlight is lit, but screen is blank. This question was solved. View Solution.

  • Help interpreting  v$rowcache_parent output

    Hi, what saddr = 00 means in that output : SQL> select count(*) , saddr from v$rowcache_parent group by saddr order by 1 desc;   COUNT(*) SADDR     413532 00          2 00000001DF739E88DB is RAC 10.2.0.3 . Regards. Greg

  • My ipad freeze and cannot shut down

    My ipad freeze while my daughter is playing her kids game.i try to shut down the ipad by pressing the start button but it wont help and now battery is drained flat.What can i do after recharging it.Tx


HashFlare