CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 2006
    Posts
    21

    Problem with printing, scaling, dpi

    Hi - I have some problems with printing. I made simple report, that needs to be printed. Everything was ok till I changed the printer - the printout doesn't fit the paper it's twice bigger. I have a class that implements Printeable interface:

    Code:
    @Override
        public int print(Graphics g, PageFormat pf, int pi) throws PrinterException {
    [...]
            Graphics2D g2d = (Graphics2D)g;
    
            g2d.translate((int) pf.getImageableX(), (int) pf.getImageableY());
            width = (int) pf.getImageableWidth();
            height = (int) pf.getImageableHeight();
            g2d.setClip(0, 0, width, height);
    [...]
    When I was testing printing using PDFPrinter the problem also exists. For 600dpi printout look ok but for 300dpi the printout is two times bigger and doesn't fit the paper. Scaling is not a problem - I can use g2d.scale( xfactor, yfactor) - but I don't know how to find factor - how to get value of dpi for current PrintJob? Does anyone know solution? It would be greatly appreciated.
    Greetings...

  2. #2
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    Re: Problem with printing, scaling, dpi

    Cross posted here
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured