Use paint() for print()????

I see many print examples out there on the web and such. I am wondering why for the print function, they just don't call paint() on the component they want to print.
For example, if you have a JTextArea and you want to print it, make the object implementint the Printable interface and have the print function just invoke paint() on that text area for each page. I did this, and don't see any problems. It was much quicker than formatting the text myself. I just modify the graphics object and pass it to the paint function and voila, it looks exactly like the JTextArea if the JTextArea were as big as the piece of paper. I am just wondering why the examples out there don't do it this way. Is there some problem I am going to run into? I have run into no problems so far and printing works fine.
thanks for any help/suggestions.
dean

Indeed, that's the default for Swing components. Quoting from javax/swing/JComponent.java in src.jar:
    public void print(Graphics g) {
     setFlag(IS_PRINTING, true);
     try {
         paint(g);
     finally {
         setFlag(IS_PRINTING, false);
    }I'll note two things .. one is the AWT heavyweight components cannot be printed this way. Second, what if you want the printed representation different than the screen representation? For example, you want different font characteristics on screen than on paper because printers have much higher resolution (dpi) than screens.
- David

Similar Messages

  • How to use AVDocPrintPagesWithParams for printing without any prompt dialog or alert message ?

    Hi Friends,
    I have a problem to print the pages of a pdf, but with out any dialog box prompt. So I choosed the api AVDocPrintPagesWithParams(avDoc, avDocPrintParam);
    But I don't know how to set parameter for 2nd parameter of the funtion. My requirement is I want to print pdf's using default printer of the system i.e. Print As PDF using Abode PDF print.
    Page Dimension should be same as previous, with postscript value 3 (best print).
    I have used AVDocPrintPages (AVDoc doc, ASInt32 firstPage,ASInt32 lastPage, ASInt32 psLevel, ASBool binaryOK,ASBool shrinkToFit); But it gives an error message for some pdf's that PDF may not printed correctly because font information couldn't be found.
    So can anyone let me know please how to set the parameter of AVDocPrintParam, so that I can use AVDocPrintPagesWithParams and do the same job.
    Thanks and Regards,
    Saffiuddin Sheikh.

    Dear lrosenth,
    I am into an operation where I have check whether each objects falls inside my rectangular region or not. For this I am taking help of BBox and matrix information. The problem is that when I find PDF's those have form or container objects, their matrix and BBox is depenedent on matirx of the form or container containing them.
    In most cases by adding(concetinating ) the matrix value of form and the element gives the correct matrix, BBox value, but some cases I am yet to understand the behaviours. So to avoid these form and container for our immidiate project delivery, we are using this option to print the pdf and then process for checking the position of elements.
    My original requirement is :
    How to know objects position inside a form or container ?  
    This is just an alternative time being way to achieve the task. But if you have any idea of how to detect postion of objects inside form/container then please let me know. 

  • Using Presets for Printing Panoramas

    I have created a generic preset for printing panoramas on an Epson 4900 connected to a Mac with OS 10.8.4. Using the Epson printer driver's Page Setup via Lightroom 5, I reset the length of the panorama for each print and then update the Lightroom preset. Everything else in the preset is correct for my prints (paper, profiles, etc.).
    I have, however, periodically had the problem that even after resetting the print length in the driver and updating the generic panorama preset, that the print is the wrong length (either too long or too short) even though all indications are that everything is set correctly (see below). This can occur even if I shutdown and restart Lightroom (I have also had this problem in LR4).
    I would like to known how to correctly set up a panorama so paper is not wasted due to an incorrect length.
    The following items appear to be set correctly:
    (1) Printer Driver Page Setup paper size
    (2) The Lightroom Preset for the generic panorama (Both the print size and paper size. I looked at the text of the preset settings via TextEdit) I note that there is binary information at the bottom of the Lightroom preset. Is that being correctly updated?
    (3) The print display in Lightroom (the image correctly fills the print template which is of the correct size)
    (4) The print cell size in Lightroom is the size I have set in the printer driver
    The different sized panorams were printed on different days and the printer was turned off between those days. Cut sheet prints were also printed in between the panorams.
    One panorama was 8 feet long but it was truncated at 39 inches twice before it printed correctly (after I restarted Lightroom but not the printer). The other was correctly printed 58 inches long but on 8 feet of paper (which was blank after the image).
    I find it hard to believe the printer is remembering an old size (even after being powered off) but if Lightroom is not sending new information, I suppose that is possible.
    Allyn

    Hi Venu,
    Don't know about best-practice, but you can do this by using the file adapter, using the "Run Operating System Command" to execute a print command on the file.
    The file can be formatted in a mapping program.
    Regards,
    Bill

  • Flex 3  :How to use trace for printing data in console

    Hi ,
    I heard that we can use trace to print data on to Flex Builder 3 console . But when i tries it was of no luck .
    The below is a simple program , in which i was out of luck .
    public function callMe():void
                trace("AAA");
    <mx:Button id="Register" name="Register" label="Register" height="23" click="callMe()"/>
    Here in the above porogram , after clicking the Button , i cant see 'AAA 'related  inside my Flex Builder .
    Any help ??
    Thank you .

    Hi Kiran
                Make a break point at trace line and debug the application  There u can find the message u typed in console..  trace works only under debugging mode... not in development mode ..
               Have a nice day
    Thanks
    Ram

  • Setup Problem HP6830 using Hotspot for Printer & Laptop

    I have a TMobile Hotspot that gives me internet access for my laptop.I have a HP Officejet Pro that I just got and I'm trying to set it up on the Hotspot network.I've installed (via disk) the HP Software on my Toshiba Coimputer.I've gone through the setup process on the printer and it shows I'm connected to the Hotspot Network.When I try to go through the setup process on the computer it says it can't find that printer.I've checked - over and over again - the IP, and printed everything out (Config Page & Network TestResults) on the Printer, and it indicates everything is OK. My question is - Why can't my computer find the computer (they're both on the same Hotspot Network)?I don't have a USB Cable right now, and I'm trying to set it up wirelessly.  Any suggestion about what I might have missed?  Any help would be appreciated

    Hey ,  Welcome to the HP Support Forum.  I understand you're encountering some setup issues when using your HP Officejet Pro 6830 e-All-in-One Printer with a mobile hot spot.  I would like to assist you with this.   In my experience, mobile hotspots are hit and miss when used to support printers' wireless connections, even when the setup's are completed with diligence and care on the part of the user.  This caveat aside, as there are no official documents from HP on how to troubleshoot this particular issue, I recommend  toggling airplane mode on your T-Mobile device before restoring the hotspot connection.  Try the printer to laptop connection via the software as before, once you've confirmed the laptop's connected to the hotspot.  If this approach falls short, you could try the alternative and HP supported wireless direct setup method.  Here's how: From your printer's front panel touch the Wireless Direct icon ()Turn Wireless Direct OnFrom here you can choose to have it enabled with Security On or Off.  If you turn Security On, make a note of the passcode (it'll come in handy later).To learn how to complete the setup on your computer and any other mobile devices, click here for more instructions. Please let me know the result of your troubleshooting by responding to this post.  If I have helped you resolve the issue, feel free to give me a virtual high-five by clicking the 'Thumbs Up' icon below and clicking to accept this solution. Thank you for posting in the HP Support Forum.  Have a great day!

  • Using paint() for a JPanel in a ScrollBar

    i have a class that extends JPanel and paints some graphics in it using the function paint(). like g.drawString.. i had to add an instantition of that class in the container of my main class within a scrollbar. It initially painted well but when i scroll, it gets distorted. its something like this
    public class PaintedPane extends JPanel
    public PaintedPane()
    paint()
    other codes here..
    public class MainClass extends JFrame
    public PaintedPane pane;
    public JScrollbar scroll;
    public MainClass()
    pane = new PaintedPane();
    scroll = new JScrollBar(pane);
    it seems that the pane wont update the part of the pane not initially exposed because of the scrollBar. how can i fix it? thanks!

    sorry for the wrong section.
    here is the code:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class MainClass extends JFrame
         public TextDraw td;
         public JScrollPane pane;
         public Container c;
         public MainClass()
              c = getContentPane();
              c.setLayout(new FlowLayout());
              td = new TextDraw();
              td.setPreferredSize(new Dimension(300, 300));
              pane = new JScrollPane(td);
              pane.setPreferredSize(new Dimension(300, 200));
              c.add(pane);
              setSize(400, 400);
              show();
         public static void main(String args[])
              MainClass m = new MainClass();
              m.addWindowListener(
                   new WindowAdapter()
                        public void windClosing(WindowEvent e)
                             System.exit(0);
    }and another java file for the TextDraw
    import javax.swing.*;
    import java.awt.*;
    public class TextDraw extends JPanel
       public TextDraw()
             setBackground(Color.WHITE);           
                setSize(500,  500);
                show();
       public void paint(Graphics g)
              for(int x = 0; x < 20; x++)
                   g.drawString("Hello world!", 20, (x)*20);
                   g.fillRect(5, (x)*20, 10, 10);
    }i dont realy know what to do to fix this. And if i chang the values of the "setSize(400, 400)" of the MainClass to "setSize(300, 300)" it works fine. why is it like that? sorry im not very familiar with all the paint, paintComponent and graphics things. thanks!

  • How we use hpeprint for printing a return label of a company comes in email through a link

    For using eprint i have to attach documents with email....but how can i print my return label from a company which comes in a link and get print only when we open the link.By opening the link the label comes with popup print the page. when we select print ,asking fr the printer ....in that case hoe can we use eprint.......plz let me know

    Oh.  Okay.  You should be able to use traditional printing if you are printing form a computer.  What printer are you using?
    -------------How do I give Kudos? | How do I mark a post as Solved? --------------------------------------------------------

  • Using InCopy for print and DPS

    We are just starting a workflow of print and DPS going simultaneously by using InCopy files as our main text. We are currently working out some kinks, but one thing has me perplexed.
    I have a case where I have a paragraph in the DPS layout that I need to adjust tracking. But when I check it back in after making the change, it then changes the tracking in the print document as well. I guess I'm a little surprised that the kerning attributes are tied to the InCopy file. I should add that I do have a style sheet set up in both DPS and print with the same name but different attributes, so that is working well.
    But, I see this as a problem that will come up a lot. For example, on one document I may have a widow that I need to fix by tracking in or out--but I do not want to change the tracking in the other document.
    Is there any workaround for this (short of breaking the InCopy link)?

    It makes perfect sense, really. You’re using InDesign styles in a similar way that you’d use CSS to style HTML.
    Apply different CSS files to the same content and you get different results for the same content. But if you use an inline style in the HTML, you can’t control it externally.

  • HT1515 Does the airport express need to be connected to router  if you are using USB for printer?

    My thinking was I could connect airport express to printer by USB and it would work without connecting it using CAT5 to router. Am i wrong??

    This should work fine if the Express is connecting to a wireless network provided by another Apple router.  Is that the case here?

  • Using XI for printing

    Hi All,
    We have one requiremnt ie Printing Billing documents by third party vendor.
    Large volume of information need to be printed by remote printer.
    Scenario SAP-ISU-XI-printer Is suggestable or not, whether it is coming under best practice even if it is possible.
    Pls help me in taking big decision.
    Regards,
    venu

    Hi Venu,
    Don't know about best-practice, but you can do this by using the file adapter, using the "Run Operating System Command" to execute a print command on the file.
    The file can be formatted in a mapping program.
    Regards,
    Bill

  • I just bought a wireless officejet 4500 and am trying to make my ipad 2 be able to use it to print

    being stupid about wireless printers i thought all i had to do was buy a wireless printer and my ipad 2 could use it for printing. i have installed the printer wirelessly via my router to my desktop with windows vista 64 bit. is there any way to get it to airprint enable or whatever i need to be able to use it with my ipad
    This question was solved.
    View Solution.

    Hello bluenitro1,
    You may be able to print to your OfficeJet 4500 Wireless by downloading the HP ePrint home & biz app from the App Store. I believe the app does support this printer but it may also depend on your routers configuration for this to work successfully.
    You may also want to look into Google Cloud Print for an alternative mobile printing option. Some more information on this can be found at:
    http://support.google.com/cloudprint/bin/answer.py?hl=en&answer=1686197
    Hope this helps.
    If I have solved your issue, please feel free to provide kudos and make sure you mark this thread as solution provided!
    Although I work for HP, my posts and replies are my own opinion and not those of HP.

  • Formatting for print

    I have read about using CSS for printing out your pages so
    that you dont
    have to create 2 copies of each page you want printed.. but i
    cant find how
    to actually put it to use..
    I have added the necessary code to my CSS file.
    I have changed the media type to media="print"
    and all i keep reading is that this allows you to have the
    same page
    formatted for print..
    But how exactly do i call the same page for print? do i add a
    link to the
    page saying click here to print? if so what woudl the link
    actually point
    to?
    or by just including the right code, when the end-user choses
    to click print
    within there browser that knows to display the same page
    using the
    print.css?

    "DC" <[email protected]> wrote in message
    >I have read about using CSS for printing out your pages
    so that you dont
    >have to create 2 copies of each page you want printed..
    but i cant find how
    >to actually put it to use..
    >
    > I have added the necessary code to my CSS file.
    > I have changed the media type to media="print"
    >
    > and all i keep reading is that this allows you to have
    the same page
    > formatted for print..
    >
    > But how exactly do i call the same page for print? do i
    add a link to the
    > page saying click here to print? if so what woudl the
    link actually point
    > to?
    >
    > or by just including the right code, when the end-user
    choses to click
    > print within there browser that knows to display the
    same page using the
    > print.css?
    >
    The browser display will always be the same, whether you have
    a print CSS
    option or not.
    The arrangement is -
    You have one style sheet for your screen layout say
    "screenstyle.css" and
    one for your print layout say "printstyle.css"
    You ad both style sheets to your page code -
    <link href="screenstyle.css" rel="stylesheet"
    type="text/css" media="screen"
    />
    <link href="printstyle.css" rel="stylesheet"
    type="text/css" media="print"
    />
    When a user views your page on their screen it is laid out
    according to your
    screenstyle.css style sheet.
    When the user prints the page, the printed output is laid out
    according to
    you printsyle.css style sheet.
    Hope this helps
    Regards
    Phill
    P&M Software
    www.pmsoftware.co.uk

  • Has anyone used Motion for 'still graphics' (300dpi)?

    I used Motion a lot several years ago on a film. Great app. I'm producing a series of Ebooks right now, with many graphics. I'm using Pages, Photoshop, EasyDraw, for the graphics ... but remember how marvelous Motion was.
    I'm wondering if it is possible to use Motion just for doing still graphics? And how one might set the resolution to reflect this (something like 300 dpi), ... or can one set any size (a very large 72dpi (given it's designed for motion and video) that can then be translated to 300 dpi after the fact.
    If anyone has ever used Motion for simple non-motion graphics, I'm all ears,
    Ben

    First of all, create a new document in Photoshop: enter your output format (US Letter, A4, whatever) with 300 dpi settings. Then change your units from to pixels and that is the size that your motion project should have.
    Remember though, that Motion outputs only in RGB that has a much wider gamut than CMYK, which is the colorspace of print. So you might still have to color proof your image in Photoshop.
    Also, depending on your graphics card, Motion has a limit of image sizes it can work on: 2K, 4K or 8K in the current models. For large print formats that could be not enough.
    I would never use Motion for print jobs. However I can imagine that I could export (with transparency) some effects like stills from animated particles, 3D replicators and import them into my photoshop composition. So Motion could be used more like an extra tool.
    Michal

  • Color Space Question For Printing

    I have multiple newbie questions so please bear with me
    Normally when working in photoshop, I tend to use the RGB color space as I need the use of filters and other effects not available in CMYK, Now when printing flyers E.g A4 Sized I tend to save the PSD in RGB (Without Flattening) and then importing it into a CMYK color space in illustrator and then exporting as a PDF, as illustrator gives me the option to create bleed as well as trim marks, I have never exported a PDF from photoshop as it always gives me the option of photoshop pdf which is kinda heavy.
    My question is, is the process I use okay for printing? or do I first need to convert it into CMYK? or just export from photoshop itself?  Also, the other reason I use illustrator is if i'm making a business card with two sides, since text is better exported from illustrator.
    Could anyone tell me a simpler process for creating for digital print? Especially if I need to do some items in illustrator as well.

    >> images are still a bit washed out with a warmish/ yellow cast to them, particularly, my black and white images
    Here is a simple test to help evaluate if the monitor profile is reasonably good:
    Open a RGB file in Photoshop (flatten if not already flattened).
    Press M key> Drag a selection> Com+Shift+U (Desaturate).
    Com+Z (to toggle back and forth).
    If the unsaturated selection looks neutral you've got a reasonably fair monitor profile.
    If selection has color casts (not neutral) -- you have a bad monitor profile
    +++++
    Here is a simple test to help evaluate if a bad monitor profile is whacking out your Photoshop color:
    Monitors/Displays (control panel)> Color> highlight AppleRGB or sRGB (don't run Calibrate), quit and reboot.
    If the Photoshop colors are back under control, then the problem was most surely a bad monitor profile go back into Monitors/Displays> Color and Calibrate a good profile highlight (load) sRGB, or preferably, the monitor's OEM profile as a starting point.
    If you are using a puck, it is likely defective; or your monitor hardware is the culprit...search it on Google by model number

  • Specify wifi for printing

    Is there a way to tell my computer to use wifi for printing and the ethernet for everything else (i.e. internet, mail, etc.)? With both ethernet and wifi networks connected, my computer fails to find the printer. When I turn off the ethernet network, my computer is able to find the printer.
    Any suggestions are greatly appreciated.

    2 possible causes:
    1. If the printer is connected to the network by both wi-fi and ethernet cable, it may not work properly. My HP printer insists I only have one connected or it just sulks
    2. Your network may not be set up properly
    If you can give more details (how the wi-fi and ethernet networks are set up, what kind of printer, how it's connected etc), it'll help

Maybe you are looking for