Advanced Printing Topic

Hi All !!
My Name is Carl & developed a java application using SWING the GUI is great you can see the it in next URL http://www.cs.buap.mx/~carlo/images/Minesys.jpg
but it's very poor without a interesting print interface, how i do print the JTtextFields & the JTable in a sheet

Your link doesn't work and your question is too vague, but here's code to print a gui component
StandardPrint.java
===============
package tjacobs.print;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.awt.print.*;
import javax.print.PrintException;
* StandardPrint is pretty groovy. This is one of my most used classes
* This implements the Printable and Pageable java.awt.print interfaces
* Allows you to very easily and quickly generate a printout from a component
public class StandardPrint implements Printable, Pageable {
    Component c;
    SpecialPrint sp;
    PageFormat mFormat;
     boolean mScale = false;
     boolean mMaintainRatio = true;
    public StandardPrint(Component c) {
        this.c = c;
        if (c instanceof SpecialPrint) {
            sp = (SpecialPrint)c;
    public StandardPrint(SpecialPrint sp) {
        this.sp = sp;
     public boolean isPrintScaled () {
          return mScale;
     public void setPrintScaled(boolean b) {
          mScale = b;
     public boolean getMaintainsAspect() {
          return mMaintainRatio;
     public void setMaintainsAspect(boolean b) {
          mMaintainRatio = b;
    public void start() throws PrinterException {
        PrinterJob job = PrinterJob.getPrinterJob();
        if (mFormat == null) {
            mFormat = job.defaultPage();
        job.setPageable(this);
        if (job.printDialog()) {
            job.print();
    public void setPageFormat (PageFormat pf) {
        mFormat = pf;
    public void printStandardComponent (Pageable p) throws PrinterException {
        PrinterJob job = PrinterJob.getPrinterJob();
        job.setPageable(p);
        job.print();
    private Dimension getJobSize() {
        if (sp != null) {
            return sp.getPrintSize();
        else {
            return c.getSize();
    public static Image preview (int width, int height, Printable sp, PageFormat pf, int pageNo) {
        BufferedImage im = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        return preview (im, sp, pf, pageNo);
    public static Image preview (Image im, Printable sp, PageFormat pf, int pageNo) {
        Graphics2D g = (Graphics2D) im.getGraphics();
        int width = im.getWidth(null);
        int height = im.getHeight(null);
        g.setColor(Color.WHITE);
        g.fillRect(0, 0, width, height);
        double hratio = height / pf.getHeight();
        double wratio = width / pf.getWidth();
        //g.scale(hratio, wratio);
        try {
               sp.print(g, pf, pageNo);
          catch(PrinterException pe) {
               pe.printStackTrace();
        g.dispose();
        return im;
    public int print(Graphics gr, PageFormat format, int pageNo) {
        mFormat = format;
        if (pageNo > getNumberOfPages()) {
            return Printable.NO_SUCH_PAGE;
        Graphics2D g = (Graphics2D) gr;
          g.drawRect(0, 0, (int)format.getWidth(), (int)format.getHeight());
        g.translate((int)format.getImageableX(), (int)format.getImageableY());
        Dimension size = getJobSize();
          if (!isPrintScaled()) {
             int horizontal = getNumHorizontalPages();
             int vertical = getNumVerticalPages();
             int horizontalOffset = (int) ((pageNo % horizontal) * format.getImageableWidth());
             int verticalOffset = (int) ((pageNo / vertical) * format.getImageableHeight());
             double ratio = getScreenRatio();
             g.scale(1 / ratio, 1 / ratio);
             g.translate(-horizontalOffset, -verticalOffset);
             if (sp != null) {
                 sp.printerPaint(g);
             else {
                 c.paint(g);
             g.translate(horizontal, vertical);
             g.scale(ratio, ratio);
          else {
             double ratio = getScreenRatio();
             g.scale(1 / ratio, 1 / ratio);
               double xScale = 1.0;
               double yScale = 1.0;
               double wid;
               double ht;
               if (sp != null) {
                    wid = sp.getPrintSize().width;
                    ht = sp.getPrintSize().height;
               else {
                    wid = c.getWidth();
                    ht = c.getHeight();
               xScale = format.getImageableWidth() / wid;
               yScale = format.getImageableHeight() / ht;
               if (getMaintainsAspect()) {
                    xScale = yScale = Math.min(xScale, yScale);
               g.scale(xScale, yScale);
               if (sp != null) {
                    sp.printerPaint(g);
               else {
                    c.paint(g);
               g.scale(1 / xScale, 1 / yScale);
               g.scale(ratio, ratio);
         g.translate((int)-format.getImageableX(), (int)-format.getImageableY());     
        return Printable.PAGE_EXISTS;
    public int getNumHorizontalPages() {
        Dimension size = getJobSize();
        int imWidth = (int)mFormat.getImageableWidth();
        int pWidth = 1 + (int)(size.width / getScreenRatio() / imWidth) - (imWidth == size.width ? 1 : 0);
        return pWidth;
    private double getScreenRatio () {
        double res = Toolkit.getDefaultToolkit().getScreenResolution();
        double ratio = res / 72.0;
        return ratio;
    public int getNumVerticalPages() {
        Dimension size = getJobSize();
        int imHeight = (int)mFormat.getImageableHeight();
        int pHeight = (int) (1 + (size.height / getScreenRatio() / imHeight)) - (imHeight == size.height ? 1 : 0);
        return pHeight;
    public int getNumberOfPages() {
          if (isPrintScaled()) return 1;
        return getNumHorizontalPages() * getNumVerticalPages();
    public Printable getPrintable(int i) {
        return this;
    public PageFormat getPageFormat(int page) {
        if (mFormat == null) {
            PrinterJob job = PrinterJob.getPrinterJob();
            mFormat = job.defaultPage();
        return mFormat;
SpecialPrint.java
=============
* Created on May 24, 2005 by @author Tom Jacobs
package tjacobs.print;
import java.awt.Dimension;
import java.awt.Graphics;
* Interface for using StandardPrint with something other than a Component or something
* that needs special printing
public interface SpecialPrint {
    public Dimension getPrintSize();
    public void printerPaint(Graphics g);
}

Similar Messages

  • Print topic window problems on unix

    What is used to display the list and status of printers available on unix when using the print topic menu button?
    On HPUX, the printer that I am currently using shows up as not accepting jobs even though the lpstat -a says that it is accepting requests.
    Any Ideas? Is it something wrong with my system configuration?
    I also have a few junk printed names in my list.
    Thanks in advance for any help that you can provide.

    That dialog is displayed directly by the Java Runtime Engine. There is no OHJ code involved in fetching the list of printers. I would upgrade to the latest JRE version on your platform, and if it still reproduces, contact the JRE vendor.

  • HP Deskjet 3920 advanced printer drivers will not install on my laptop

    I can't share HP Deskjet 3920 with Win 7 64 bit cause can't install advanced printer drivers for x64 on Win XP, error message like: "need some drivers from Windows XP CD-ROM" - and can't find it there (need for sRGB.ICM file).
    If I manually point this file, the install process loops endlessly.
    Spoiler (Highlight to read)
    Spoiler (Highlight to read)
    Spoiler (Highlight to read)

    Hi Yaugen,
    Try these instructions.  The main task is to get Windows XP and Win7 to share resources.
    Step one: Windows 7 Homegroup must be setup
    Printer sharing must be setup in the Homegroup settings, if one of the computers in the network is using Windows 7.
    1. Click Start
    2. Click Control Panel
    3. In the upper right corner ensure that View by has Large icons or Small icons selected.
    4. Click Network and Sharing Center.
    5. Click Choose homegroup and sharing options
    6. If the Homegroup is not setup, you need to set up your homegroup before continuing.
    Step two: Set the Workgroup on each computer
    Each computer on the network must be set to the same Workgroup.  The workgroup name needs to be changed from the default to a new name.
    Windows XP:
    1. Click Start.
    2. Right click Computer and then left click Properties.
    3. The default Workgroup is WORKGROUP. 
    4. The name of the Workgroup should be changed from the default.
    5. In System Properties, click the Computer Name tab.
    6. Click the Change button.
    7. Enter the Workgroup name that is used by your entire network.  If you are changing the Workgroup name, use the same name used in Windows 7.
    8. Click OK.
    9. You must restart your computer for the change to take effect.
    Windows 7:
    1. Click Start.
    2. Right click Computer and then left click Properties.
    3. The Workgroup is listed in System Properties.
    4. The default Workgroup is WORKGROUP. 
    5. The name of the Workgroup should be changed from the default.
    6. Change your Workgroup in Windows 7 by clicking Change settings.
    7. Click the Change button.
    8. Enter a new Workgroup name that will be used by your entire network.
    9. Click OK.
    10. You must restart your computer for the change to take effect.
    Step three: Setup a share account on each computer in the network
    Create a common share account on each of the computers, including the computer that is sharing the printer to the rest of the network.  This share account must have the same name and password on each computer.
    If you decide to use an existing account that appears on each computer all ready, this existing account must be password protected. If you do not want to password protect your default login, create a new share login as described in the following steps.
     Windows XP
    1. Click Start
    2. Click Control Panel
    3. Click User Accounts
    4. Click Create a new account.
    5. Enter the same user account name created as the share account on the Windows 7 computer.
    6. Click Next.
    7. Under “Pick an account type”, select ‘Computer Administrator’.
    Note: In Windows XP you must select Computer Administrator in order setup a printer.
    8. After you new account is created, select it under ‘pick an account to change’.
    9. Click Create a password
    10. Enter the same password used when creating the share account on the Windows 7 computer, following the directions on the screen.
    11. Click Create Password button.
    12. Log off your current user account and log into the new share account to activate it.
    13. Once the computer is ready after logging into the share account, you can log off the share account and back into your regular user account.
    Windows 7
    1. Click Start
    2. Click Control Panel
    3. In the upper right corner ensure that View by has Large icons or Small icons selected.
    4. Click User Accounts
    5. Click Manage another account
    6. Click Create a new account
    7. Select Standard User
    Note:  The account created should be created with the lowest security setting necessary.  Creating the share account as an administrator is discouraged.
    8. Enter a new user account name.  Use a name that is easy to remember as the account used for sharing resources across your network.  For example: ‘ShareAccount’
    9. After your new account is created, select it under “Choose the account you would like to change”.
    10. Click Create a Password
    11. Enter a new password, following the directions on the screen.
    12. Click Create Password button.
    13. Close any remaining opened windows, making a note of the new account name and password as you will need to create identical accounts and passwords on the other computers on your network.
    14. Log off your current user account and log into the new share account to activate it.
    15. Once the computer is ready after logging into the share account, you can log off the share account and back into your regular user account.
    Step Four: Share the printer to the network
    The computer that has the printer attached and installed by USB must have the printer shared to the network.
    Windows XP
    1. Open the printers and faxes folder in Windows XP.
    Note: A hand symbol under the icon for the printer indicates it is already shared to the network.
    2. Right click on the printer to be shared to the network.
    3. Left click on Sharing.
    4. Click “If you understand the security risks but want to share printers without running the wizard, click here”.
    5. Select “Just enable printer sharing”.
    6. Click OK.
    7. Select “Share this printer”.
    8. If the Share name is acceptable, click OK.
    9. If you want to change the Share name, enter a new name. Click OK.
    Note: If the Share name entered is longer than 8 characters, you will get a warning that the printer will not be accessible from MS-Dos computers.
    Step five: Install the appropriate software for your printer
    Install the printer software on the other computers on the network that will need to access the shared printer.  Install the correct driver for the printer model for each computer on the network. Not all printers will need to have a driver installed, only newer printers.
    1. Check for available drivers – visit the HP website and download available drivers.
    Note: Even if you have an install CD for your older HP product, there may be an updated driver for your printer.
    2. Launch the driver setup by double-clicking on the downloaded driver.
    3. If the driver install process requires you to attach the printer USB cable to continue, click cancel instead.  This will roll back the install, but it will leave the driver files installed. 
    4. Select the USB connection type. Look for the checkbox labeled “Connect later – Do not connect to the printer now.  I will connect it later”. 
    Note: You might have to select USB connection type before the checkbox is visible.
    5. Complete the install without attaching the USB cable.
    6. After the software is installed, delete any icons created on the desktop.  They will not be linked to the shared printer and will only result in errors if used.
    Step six: Install the shared printer.
    Note: Computers that are not sharing a resource to the network may not show up by name when viewing the entire network.
    Windows 7
    1. Click Start.
    2. Click on Computer.
    3. In the lower left pane, click on Network.
    4. Double click on the computer that is sharing the printer.
    5. Enter the name of your share account as the “User name”.
    6. Enter the same password created for the share account.
    7. Check the box labeled Remember my credentials.
    8. Click OK.
    9. Right click on the printer, left click Open.
    10. Windows will find the previously loaded driver for the printer and complete the install.
    I was an HP employee.
    Please mark the post that solves your problem as "Accepted Solution"

  • Standard/Advanced print dialogue for PDFs?

    When you print an image such as a jpeg in Mac OS X 10.4 you get the option of standard or advanced print dialogues. One feature of the Apple's new standard option allows for rotating an image on the print area. This is great because it potentially allows us to print A2 on our large format printer without having to then trim it manually. Except that most of our printing is done from PDFs which don't appear to be able to take advantage of this standard print dialogue.
    Question is, does anyone know of a way to invoke the standard print dialogue for PDFs?

    When you print an image such as a jpeg in Mac OS X 10.4 you get the option of standard or advanced print dialogues. One feature of the Apple's new standard option allows for rotating an image on the print area. This is great because it potentially allows us to print A2 on our large format printer without having to then trim it manually. Except that most of our printing is done from PDFs which don't appear to be able to take advantage of this standard print dialogue.
    Question is, does anyone know of a way to invoke the standard print dialogue for PDFs?

  • Print Preview in CM14 after Edit BI Report not working; Advance print is

    I created a custom Form in BI Publisher for the Payment requisition Module.
    I have already imported it in CM14 Admin site so it does show up in CM14.
    I have also made this the default form for this group.
    After I edit the report format in RTF and upload it, I go back to CM14 and click print preview, and none of the changes i made are shown. If i go to advance print and preview the same Form, the changes are shown.
    The only way i can get the print preview to show the changes is to go into CM14 Admin and upload it.
    The cache options are all off for the form. I am using PCM 14.0.3.0 Build 2458 and Oracle BI Publisher 11.1.1.6.7 
    Any ideas why print preview is not showing the changes but advance print is?
    Thank you for your help in advance.

    I have not seen this before, but would suggest:
    1.  You may want to try clearing your browser and java cache and see if that fixes the problem.
    Also, I have seen where form changes didn't push through when modifying the same form that existed unless you did a new Import Forms in Admin when the form or report had a PROMPT for criteria included.  So I'm not sure if something like that is occurring.
    Basically, you're saying that the print preview works correctly after doing an Import Forms but not before, right?

  • How can set custom advanced print setting to default?

    Hi
    I am using job automation program called enfocus switch and
    Every time it automatically print out  PDF file, i wanted it to be printed out with bleed mark and page information.
    As i go to advanced print setup, i can achieve this by set setting to custom setting that has checked bleed mark and page info.
    Is there any way to set custom setting as default so Evey time enfocus program print out PDF, it is printed out with bleed marks and page info.
    Thanks

    this is what i wanted it to be default. checked bleed marks & page information
    went to setting-adobePDF. coudn't find any thing related to bleedmark and page info.
    Hope this give you more detail thank you for your time.

  • How Do i disable ""enable advance Printing features on windows server 2008 ""

    Hi ,
    I have a windows server 2008 which is used as  a terminal server . Users at remote locations log on to this server via "" DYNDNS"" to user our ERP and company files. We use ""DOT MATRIX PRINTERS "" to print  . As we all know that ""enable advance
    printing feature"" is checked by default on windows server 2008 the format of our ""DOT MATRIX PRINTOUTS "" CHANGE  which creates a big mess. 
    I would like to know if there is any way where i can disable this feature permanently. 

    In previous operating systems, that setting was for designed for  disabling and enabling GDI rendering on the server.  Since you are using a TYPE 4 print driver, there is no GDI rendering and thus this setting is not configurable. 
    If you would like to change this setting, you will need to use a TYPE 3 print driver that does not use XPS rendering.  Then the previous configuration methods you were using will work.
    Alan Morris Windows Printing Team

  • Load an Advanced Print Setting in Acrobat via Java-Script

    Hi there,
    I'd like to know, if there's a way to load an advanced print setting in the Acrobat via Java Script or some other way? (See Screenshot)
    Or is it possible to set an created setting as default-setting? (also via Java or something)
    Or can somebody tell me, where these created print settings are saved? (in Acrobat X)
    Thank you very much for your help and sorry for my english, I hope you understand me. :-)
    Kind regards
    Mankro

    Why wouldn't you want to set itas part of an input/output parameter?
    This is really the right way ofdoing this. Otherwise you'll end up with hardcoded variable name in your customcomponent and that not ideal.
    If you're trying to define a default value for it coming from a properties file, you can just make it a "Configuration" variable and set the value from adminui.
    Jasmin

  • Crystal 10 RCD and Windows (Advanced) Print Dialog Box

    Years ago I wrote a Crystal Viewer program and Crystal Support showed me how to change the Viewer Print Dialog box so it would use the Advanced Print Dialog (I believe it used the Windows Print Dialog). Does anyone know how to set the RDC Viewer to use a Print Dialog that allows changing the printer and not just the default Print Dialog box that only shows settings for the default windows printer? I no longer have the source code for the program I wrote before and can't remember what to set and I have now written a new Viewer that I want to include the ability to change printers.

    Ahhh, what you're looking for is descibed in note #[1212245|http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_erq/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes.do] - How to use the Printer Setup dialog box.
    Ludek

  • Advanced print settings not working in cs6

    Since updating to Yosemite, I cannot access the advanced print settings for my Epson 3880.  I have the latest driver for the 3880.  No longer can select the paper, profile, etc.

    Problem Solved:
    After uninstalling a previous version of Labview Runtime from the target machines and installing the newest version (which is consistent with my development environment) on the target machines, the Print Report.vi and all other report generation VI's I use seem to work fine.
    Also important is to make sure that the lvrt.msi file on the development machine is up to date and consistent with the version of runtime on the target machines. This does not update automatically when upgrading to a newer version of labview (at least not when I updated from 6i to 6.02). It must be manually downloaded and inserted into the proper folder.
    Thank you Ray at NI support.
    Tom S.

  • Advanced printer settings

    In the advanced printing option I can choose if I want to turn gray scale off and use blank ink cartrige only.
    How do I make this the default??????
    I only want to print out in black and not always have to go in and change this setting each print job.
    This question was solved.
    View Solution.

    That's what I have to do every time I want to print. Now, how do I make that it ALWAYS stays on use black ink cartrige only is my problem.

  • Changing advanced printing defaults

    Hi Everyone,
    Some how my default advanced print setting have changed to print as image. I want to change the default back to reugualr printing and not print as image. It's getting annoying  to have to change it back every time I want to print something. I am using Acrobat X on a Mac 10.6.8. Probably a simple fix I just cant remember or find any clear answer on line.

    No way, this is so annoying. I have been logging feature requests and whenever I meet someone from the Adobe team I'm insisting on being able to choose between absolute and relative timing. Really hope that they will listen in a near future   My work flow is to make sure that the object timing is done before applying effects.
    Lilybiri

  • Copyright Shown When Printing Topics Only

    Hi All,
    I'm told that we used to be able to display a copyright
    statement only when the user would print topics using WinHelp. The
    copyright would not display when viewing.
    I'd like to do same thing using RoboHelp HTML Help. Is there
    a way to do this?
    So far I've explored footers and templates but to no avail.
    Any help would be appreciated.
    Thanks!
    Larry

    Hi Pete,
    Well, it worked great.
    First, on getting the compiled Help file to open up, I had to
    run MJs Help Diagnostics to get the DLLs registered properly. I
    believe the problems cropped in when I installed Flare -- our new
    Help tool.
    Then, I was able to get the citation working properly with
    your excellent instructions. I placed the following in the style
    sheet for each topic.
    @media screen
    p.copyright { display:none; }
    @media print
    p.copyright { display:block; }
    Unfortunately, the Help system currently uses a number of
    style sheets rather than just one, but it still only took a couple
    minutes to put that code in each .css file.
    Then I added the following to the TrueCode of a template
    footer.
    <p class="copyright">Copyright © 2008 Scantron
    Corporation. All rights reserved. Use permitted only under license.
    No part of the Help may be reproduced in any form, or by any means,
    without permission from Scantron Corporation. www.scantron.com
    I was able to apply this to all 1700 help topics in one fell
    swoop. That saved me a lot of work. At first there was a style
    sheet associated with the template file. This switched each topic's
    style sheet to the template's when I applied the template to some
    sample topics. So I removed the .css file association with the
    template, and then it worked like a charm.
    Thanks again for the insight. I really didn't think that I
    had a chance to provide that functionality when QA requested it.
    Larry

  • Canon 5030 advanced printer drivers will not install on my hp dv6000 laptop

    my  company is trying to install their canon 5030 advanced printer drivers onto to dv6000 laptop so i can print at work and they will not install.  there are no error messages it just won't install.  i do not, cannot get a new laptop. i need to make this work. HELP
    my os is xp  sp2 with most recent updates installed.

    You would probably get better luck with your question if you post this on the HP Notebook board as this board mainly deals with hp printers and the Notebook board will help with your HP Laptop.
    Good Luck !
    If I helped you at all it would be great if you clicked the blue kudos star!
    If I solved your post please mark it as solved to help others.
    I'm a printer tech with HP.

  • Acrobat Pro - advanced print settings

    Hello,
    my system: Adobe Acrobat Pro 10.1.7
    I want to change the settings under file - print - advanced
    the settings under "Acrobat default" and "Custom" are not modifiable
    do someone know how it works?
    thanks K.W.

    Only the fields supported by the selected printer driver are active on that dialog; for example if you don't have a PostScript printer, that section is turned off.

Maybe you are looking for