Unwanted margins when printing images

All,
I have an application that loads images from a chosen directory and loads them into tabs. I then have print options. All is fine printing however there is a 1" border around the image. This seems to squish the image smaller which results in more difficulty reading.
I have aquired a PrintImage class for GIF's somewhere from the Sun site and modified it to also accept JPG and PNG. Can anyone give an idea on how set the margin attributes from this code?
public class PrintImage {
    public void PrintImage(String path, String type) {
        /* Use the pre-defined flavor for a GIF from an InputStream */
        DocFlavor flavor = null;
        if (type.equals("gif")) {
            flavor = DocFlavor.INPUT_STREAM.GIF;
        } else if (type.equals("jpg") || type.equals("jpeg")) {
            flavor = DocFlavor.INPUT_STREAM.JPEG;
        } else if (type.equals("png")) {
            flavor = DocFlavor.INPUT_STREAM.PNG;
        /* Create a set which specifies how the job is to be printed */
        PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
        aset.add(MediaSizeName.NA_LETTER);
        aset.add(new Copies(1));
        /* Locate print services which can print a GIF in the manner specified */
        PrintService[] pservices =
                PrintServiceLookup.lookupPrintServices(flavor, aset);
        if (pservices.length > 0) {
            /* Create a Print Job */
            DocPrintJob printJob = pservices[0].createPrintJob();
            /* Create a Doc implementation to pass the print data */
            Doc doc = new InputStreamDoc(path, flavor);
            /* Print the doc as specified */
            try {
                printJob.print(doc, aset);
            } catch (PrintException e) {
                System.err.println(e);
        } else {
            Component frame = null;
            JOptionPane.showMessageDialog(frame,
            "No suitable printers.",
            "Print error",
            JOptionPane.ERROR_MESSAGE);
    public static void main(String args[]) {
class InputStreamDoc implements Doc {
    private String filename;
    private DocFlavor docFlavor;
    private InputStream stream;
    public InputStreamDoc(String name, DocFlavor flavor) {
        filename = name;
        docFlavor = flavor;
    public DocFlavor getDocFlavor() {
        return docFlavor;
    /* No attributes attached to this Doc - mainly useful for MultiDoc */
    public DocAttributeSet getAttributes() {
        return null;
        /* Since the data is to be supplied as an InputStream delegate to
         * getStreamForBytes().
    public Object getPrintData() throws IOException {
        return getStreamForBytes();
    /* Not possible to return a GIF as text */
    public Reader getReaderForText()
    throws UnsupportedEncodingException, IOException {
        return null;
        /* Return the print data as an InputStream.
         * Always return the same instance.
    public InputStream getStreamForBytes() throws IOException {
        synchronized(this) {
            if (stream == null) {
                stream = new FileInputStream(filename);
            return stream;
}

To set a custom margin, you need to create a custom paper size. To do this, go into Page Setup, and under Paper Size choose Manage Custom Sizes. In the new dialog, click the plus sign at the bottom left to create a new size. Set the paper size to whatever you want (it should be 8.5X11" for letter, of course), and then set the margins to the size you need. Once you click the OK button, this paper size will now be available to choose in the Page Setup dialog.

Similar Messages

  • Cannot change the print margins when printing out my spreadsheet.  Tried clicking on format and then Document but when I enter a number I always get " invalid number".

         I cannot change the margins when printing out my spreadsheet.  I clicked on the format then on document and got a entry box.  But everytime I try entering a number to change the left margin ( tried .5 ) I get an " invalid number " response.  I can print out the spreadsheet but always get a message telling me the margins may be too small and data may be clipped.  Data doesn't get clipped but left part of the spreadsheet is right at the left side of the paper.  Want to change the margin so I don't get that message.

    Naming the spreadsheet app would do wonders for getting an answer.

  • A way to reduce margins when printing multiple pages per sheet?

    I really like the new leopard print dialog box. Is there a way of reducing the large margins when printing 2, 4, or more pages per sheet (in Layout)?

    You could use custom page sizes (in the Page Setup dialog) or you could see if the settings in the Paper Handling panel help at all.

  • How do I remove top and bottom margins when printing using Adobe Acrobat XI Standard.

    How do I remove top and bottom margins when printing using Adobe Acrobat XI Standard. (I selected 'Fit to scale' and there's a huge gap on the top and bottom).

    Those margins are usually reported from the printer settings to Acrobat. Meansif you have, for example, an inkjet printer and that printer can not print seamlessly, then there will be a minimum margin.
    Check your printer's page settings.

  • How to change margins when printing in landscape

    Hi all,
    I have a network printer installed on Solaris 6. To get it to print in "landscape" i added a filter - like this:
    Input types: any
    Output types: landscape
    Printer types: any
    Printers: any
    Filter type: slow
    Command: /etc/lp/landscape.sh
    The script: landscape.sh:
    echo "^[&l1O"
    cat -
    echo "^[&l0O"
    When i print like this: lp -dprinter -olandscape filename it print�s in landscape. Problem is i can�t set up any margins.
    Printer is configurated like this:
    Banner: on:Always
    Content types: landscape
    Device: /dev/null
    Interface: /etc/lp/test
    Printer type: unknown
    Modules:
    Options:
    I tried to modify it�s interface file, but that had no effect. Here are the line i tried to modify
    # PC-850, 12 cpi, 12 pkt, normal Courier, 6 col. Left Marg., 2 lin. TopMarg.
    echo '\033(0N\033(s0p12.00h12.00v0s0b3T\033&a6L\033&2E\c'
    How can i change the margins ?
    Thank u all
    Thomas

    It sounds like either the font is corrupted or your AddressBook prefs are whacked.
    You can check the font in FontBook > File> Validate Fonts, or in /Users/yourname/Library/Preferences/com.apple.AddressBook.plist move it to the desktop and restart.
    -mj

  • Extra margins when printing double sided

    I'm using Word 2007 and have created recipe cards using a basic recipe templete in Word. I have the top margin set to .25 and I'm printing on a regular 8x11 piece of card stock (I want to simply cut the sides and bottom down to make a 4x6 index card).
    However, the margin is printing at almost .75 when I print double sided. Any help would greatly appreciated! I've been working on this problem for two days and I bought the printer to print both sides.
    Thanks!

    Did you ever figure this out? Because my C309g changes my margins when I print double sided, and I can't find any info on it anywhere...!

  • Set margins when printing

    I have problems to set the margins for printing..
    I set margins in this way:
    when I start the printing process I do:
            PrinterJob job = PrinterJob.getPrinterJob();
            final Stamp canvas = new Stamp();
            job.setPrintable(canvas);
            MediaPrintableArea area = new MediaPrintableArea(10, 10, 170, 255, MediaPrintableArea.MM);
            HashPrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
            aset.add(area);
            if (job.printDialog()) { // chiede conferma definitiva
                try {
                    job.print(aset);
                } catch (PrinterException ex) {
                    Logger.getLogger(Stampa_Try_For_PreciseLocation.class.getName()).log(Level.SEVERE, null, ex);
            }in the canvas class I try to read the margins :
    public int print(Graphics g, PageFormat pageFormat, int pageIndex) {
            if (pageIndex >= 1) {
                return Printable.NO_SUCH_PAGE;
            Graphics2D g2 = (Graphics2D) g;
            g2.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
            AffineTransform at = new AffineTransform();
            at.scale(pageFormat.getImageableWidth(), pageFormat.getImageableHeight());
            g2.transform(at);
            double pageWidth = pageFormat.getWidth();
            double pageHeight = pageFormat.getHeight();
            double pageSpUsedX = pageFormat.getImageableX();
            double pageSpUsedY = pageFormat.getImageableY();
            double pageSpUsedWidth = pageFormat.getImageableWidth();
            double pageSpUsedHeight = pageFormat.getImageableHeight();
            System.out.print("larghezza pg = " + pageWidth);
            System.out.println(" ; altezza pg = " + pageHeight);
            System.out.print ("area usabile X = " + pageSpUsedX);
            System.out.println(" ; area usabile Y = " + pageSpUsedY);
            System.out.print("area usabile larghezza  = " + pageSpUsedWidth);
            System.out.println("  ; area usabile altezza = " + pageSpUsedHeight);
            g2.drawString("x as", (float)pageSpUsedX                         , (float)pageSpUsedY);
            g2.drawString("x ad", (float)pageSpUsedX + (float)pageSpUsedWidth, (float)pageSpUsedY);
            g2.drawString("x bs", (float)pageSpUsedX                         , (float)pageSpUsedY + (float)pageSpUsedHeight);
            g2.drawString("x bd", (float)pageSpUsedX+ (float)pageSpUsedWidth , (float)pageSpUsedY + (float)pageSpUsedHeight);
                    return Printable.PAGE_EXISTS;
        }But the result is not what I expected to be....
    I am working at a program that have to print 'something' on paper's labels
    placed in a normal sheet format A4.
    and for this purpose it is very important to have the contrlo where the letters are wrote..
    I don't know what it is wrong and I need some help..
    thank you in advance..
    regards
    tomyMrsangelo

    hi Andre,
    thank you to answering me,
    I tried with your code but still I have not the control that I would have printing.
    Perhaps I misunderstand the role and the means of the parameters used for set the printable
    area.......
    For example.. when I set the margins in this way:
    MediaPrintableArea area = new MediaPrintableArea(10, 10, 170, 255, MediaPrintableArea.MM);
    I expect to have one area printable with the shape of a rectangle that, on a sheet of
    paper A4 format, begin in the corner up to left in the point (5, 10) and have a horizontal size
    of 180 millimeters and a vertical size of 265 millimeters.
    But this is not happen..., I measured the horizontal side in 150 millimeters (instead 170) and
    the vertical size in 248 millimeters (instead 255)....
    Measuring the coords of the corner on top to left, I got (5, 13) and not (10, 10).
    .....I tried with other values of parameters and never I got the exact values that I expected to have.
    Having to print labels glued on a paper sheet - A4 format,
    *I need to be sure that when the statement
    g2.drawString("x", 0, 0);
    is executed
    The character x is wrote, on the paper, at the point 10, 10. *
    Perhaps
    g2.drawString("+", 0, 0);
    is not the right operation to get this target..... ????
    Regards
    tonyMrsangelo

  • Howto change left/right margin when print

    In a report we defined a left margin of 2 cm and a right margin of 1 cm.
    When printing the report simplex everything is ok.
    But when printing the report duplex we want to change the margins. Odd pages should print "normal" - but the page on the back, i.e. even pages, should then be "moved" to the left. That means the left margin has to be 1 cm and the right margin 2 cm.
    How can we achieve this behavior?

    Hi Rainer
    For information on settings for Duplex printing please refer to the below link:
    [link|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/40e40899-721e-2b10-b084-c7ed76af46f1]
    Hope this helps!!
    Regards
    Sourashree

  • Missing pages when printing images

    Hi,
    I'm fightig against a very strange problem when printing. When drawing images with g2.drawImage often everything is ok.
    But sometimes the output is incomplete - perhaps all pages after # 2 or # 7 are missing. Or no pages are missing but some images and later drawen elements of the affected pages are missing - next page will be ok.
    Printing 15 pages with 1 image per page goes wrong 2 times of 12 trys.
    Facts:
    - image is loaded completely (from database)
    - there are no ignored Exceptions
    - Thread.setDefaultUncaughtExceptionHandler is used - without response, as expected
    - all pages are requestet by print(Graphics g, PageFormat pf, int pi) and processed without errors
    - jdk 1.4.2, 1.5.0_04, 1.5.0_06 compatible ...
    - using g2.create() for the image doesn't help
    - problem exists on all printers which testet and Adobe-PDF-"printer"
    - increasing memory doesn't help
    - it seams as doubleBuffering=off will increase correct pages before get one damaged/missing
    - WinXP SP2
    Any idea?
    Thanks
    Stefan

    Thanks ! - and you are most "welcome" "lera1981" ! .........
    With respect to the printing problem with Reader 9.x and your report of your experiments with Reader 9.x and with network-printing then I tend to agree  with your assessment that it would seem as the problem is probably with Reader 9.x's printing capeability .
    Just for the record I would like to report that my experience with network-connected office-class HP printer has been that some printing problems I've seen in the past with Adobe Reader X.xx has been rectified though the change of driver-type and/or driver-generation such as a switch from e.g. a "PCL 6" driver to a "PCL 5" driver .   Last time I experienced a printing problem with a network-connected office-class HP printer I then had to change the driver to their "HP Universal Print Driver".
    While I would say that you are probably right that a change of printer-driver would not make a difference in your case then the point of my writing is that Adobe Reader X.xx or (it's interaction with) Windows seems to be "printer-driver tech-sensitive" understood as that Reader printing tends to respond differently to different "driver tech" !
    Kind Regards
    Fiat Lux !

  • Margins when printing handouts.

    When printing a handout from slides is there a way to increase the margins? Keynote prints the slides (and rules if you use them) almost right out to the edge of the page. I couldn't find anything on this in the help file.
    Thanks.
    John
    G5   Mac OS X (10.4.7)  

    To set a custom margin, you need to create a custom paper size. To do this, go into Page Setup, and under Paper Size choose Manage Custom Sizes. In the new dialog, click the plus sign at the bottom left to create a new size. Set the paper size to whatever you want (it should be 8.5X11" for letter, of course), and then set the margins to the size you need. Once you click the OK button, this paper size will now be available to choose in the Page Setup dialog.

  • HT3771 How do I adjust print margins when printing from Safari?

    When I try to print email from Safari, my messages go all the way to the edge of the paper and get cut off. I can't find any page set up adjustments for margins when in Safari, like I can in other software (Word, Excel, etc.).  All I can find are page size, orientation, etc.

    Welcome to Apple Support Communities. We're all users here.
    Let me hazard a wild guess that you're using Outlook, formerly Hotmail, for email in your web browser.
    When the forced 'downgrade' from Hotmail to Outlook occurred, they decided to hide some frequently used commands and made simple message printing from a browser print command nearly impossible, at least for Mac users.
    The trick is to use the Print command now hidden within the Outlook menu bar.
    It's in the "..." section of the Outlook top menu bar following Categories along with "Mark Read, Mark Unread, Flag, Unflag, and View Message Source".
    Select Print from there, it will open a new Outlook Print Message window. You should once again be able to print emails in their entirety.

  • HP Officejet Pro 8620 Shifted Margins when printing

    The only problem I find when printing paper is that the margins are always shifted. The margins of the paper on my PC display Is different to when Officejet Pro 8620 prints the paper. I tried printing with borderless on, but the margins are either to close to the top of the paper; I also tried printing with borderless off, but the margins shifts way below compared to the paper on the computer display. My older printer HP Officejet 4500 wireless has a "minimize margins" option, and the printer always prints exactly as it is on the display; however, it is no so with my newer Pro printer. I tried going to advanced options and clicking on preserve layout, which is available only when doing 2-sided printing, and the margins were still shifted; there are pictures on the bottom that can show you. I looked around preference options of the printer, paper setup, printer properties, tried readjusting settings, but the problem is persisting. I do not want to go any further, or else I might screw everything up. Additionally, the problem is not with the copy settings of the printer, I looked there too and the margin shift is turned off. Please help me find a solution. I use this printer to print books, and I need to finish it ASAP, thank you for your support  Printed Paper Page 1: Printed paper margins are shifted slightly higher, compared to PC display paper   Printed Paper Page 2: Printed paper margins are shifted down, compared to PC display paper   Paper Displayed on Computer: Observe the top margin distance from the top of the screen   

    Hi , Exon737 wrote:
    For the first question: Yes, when I print multiple page copies in 1-sided or 2-sided format it makes margin shifts. 1-sided printing margin is shifted down for all pages. 2-sided printing margin shifts up for odd pages and shifts down for even pages.This would mean it's something in the hardware that is causing the shifting.  HP regularly releases firmware updates that may help. You can click on this link to Get Printer Updates for HP Officejet Pro. I would also check for crumpled paper inside the printer. All of the steps can be found here, but I copied the main step for you. Check the carriage path for obstructions with a flashlight;Place your fingers into the slot on the left side of the printer, and then pull to open the cartridge access door. The carriage moves into the access area. Wait until the carriage is idle and silent before you continue.Disconnect the power cord from the rear of the printer, and then unplug the power cord from the power source or electrical outlet.Use a flashlight to check for torn pieces of paper that might remain inside the printer. 
      I would then clean the paper feed rollers, steps copied from this document.Follow these steps to clean the paper pick rollers.Place your fingers in the slot on the front of Tray 1.
    Figure : The slot on the front of Tray 1
    Pull the tray toward you to remove it.
    Figure : Pull out the input tray
    If you use Tray 2, lift the printer off Tray 2, and then set the printer aside.
    Figure : Lift the printer off Tray 2
    Turn the printer so you see its underside, and then locate the pick roller.
    Figure : Locate the pick roller
    Roll the pick roller to the right so that the rubber part faces you. This might require some force.
     NOTE:The pick roller should only rotate to the right.
    Figure : The pick roller in its normal position
    Figure : The rubber part of the pick roller
    The rubber part of the pick rollerRotate the rubber part of the pick roller so that it faces youLightly dampen a clean, lint-free cloth with bottled or distilled water, and then squeeze any excess liquid from the cloth.Press the cloth against the rubber part of the roller, and then rotate the roller to the right with your fingers. Apply a moderate amount of pressure to remove any dust or dirt buildup.Rotate the roller back to its original position.
    Figure : The pick roller in its original position
    Turn the printer back around so that the printer control panel faces you.Place the printer its normal position.Reinstall Tray 1. Then I would try aligning the printhead.On the printer control panel, swipe the display to scroll to Setup () and touch itSwipe the display to scroll then touch Tools.Touch Align Printhead.  Please let me know if any of these steps resolved your issue, or if there is anything else I can do to help.  I look forward to hearing from you!  Thanks, 

  • How to Trap REP-0108 when printing images

    I have a report that prints images off the file system.
    I have a column set to read from file with file format of image.
    Not all values will have an image. This causes the rep-0108 error.
    Any suggestions?

    Nevermind I figured something out.

  • Unwanted noise when printing in laser jet 1018

    I've been using laser jet 1018 for many years and all of a sudden it starts screech when printing. What can I do to stop this?
    If there is nothing to do but buying a new printer which other printer uses the same same toner cartridge?

    Hello magistern,
    Welcome to the HP Forums.
    The noise that you are experiencing could be cause by many different scenarios. The basis troubleshooting would include making sure the printer power cable is connected directly to a wall outlet and not a power bar/strip.  Taking a light weight lubricating oil and applying very little to the gears.
    I realize that you have had this printer for some time. If you would like to see about some out of warranty options, I suggest  calling HP's Technical Support to see about further options for you. If you are calling within North America, the number is 1-800-474-6836 and for all other regions, click here: click here.
    Thanks for your time.
    Click the “Kudos Thumbs Up" at the bottom of this post to say “Thanks” for helping!
    Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
    W a t e r b o y 71
    I work on behalf of HP

  • Image cropped off in margin when printing

    Using pages to create a postcard template. 4 images to the page landscaped. When I print the two images are cropped on the right and result in a larger margin on the right with part of images not printed even though the preview shows everything is okay. any ideas? It is like the printer is taking over the margins.

    Welcome to Apple Discussions
    Most ink jet printers, especially HPs, have a large trailing edge margin of at least .5". It is a hardware problem, not a Pages problem. Both of my laser printers print to about .15"-.18" all around. Your printer might have an option to ignore the margins or for borderless printing.

Maybe you are looking for

  • Can you have 2 iphones on one itune account

    My wife and i both have a iphone now and we currently have them both under one itunes account.  We have noticed that both of our contacts show up in each of our phones.  is there a way to keep this from happening?  Or do we need to set up two differe

  • Application does not work properly when I press a CommanButton

    Hi all, I am having a problem with weblogic 10.3.5. It turns out that an application built with JDeveloper 11.1.5, I test it, and everything goes well in the JDeveloper integrated Weblogic. But when deploy in a standalone weblogic 10.3.5 server, the

  • R/3-XI-BW

    What kind of data is transferred between R/3 to BW using XI.......could someone tell a example of this scenario....Thank you...

  • Rss feeds

    Hello All! I keep hearing that you can use rssutils.tld and rssutils.jar. Great! But where the heck are the files for downloading mc1392

  • NAC Problem_In-Band Virtual Gateway deployment

    we deployed In-Band virtual gateway deployment.. the users connected to untrusted Vlan and took IP address from DHCP where it configured on ASA that is connected to trusted interface but no one can reach to the gateway " IP address of the firewall" a