• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Zoom to actual size
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Zoom to actual size


  • Subject: Zoom to actual size
  • From: Antonio Nunes <email@hidden>
  • Date: Sat, 13 Jul 2013 23:26:18 +0100

Hi,

I'm trying to ensure that when a user elects to zoom the view (in this case a PDFView) to actual size, that it shows the actual size on-screen as best it can. I'm really close, but not quite all the way there. I tested the same function in the Preview app, and there it works perfectly. When I zoom to actual size, and hold a sheet of paper (of the same size as the PDF page) to the screen, then they match perfectly. When I do the same in my app (which uses the system provided PDFView), the on-screen page is ever so slightly smaller than the physical page (say roughly 2mm).

This is the code in its current state:

#define MILLIMETERS_TO_POINTS_FACTOR	2.834645669

- (IBAction)zoomToActualSize:(id)sender
{
    NSDictionary *screenDescription = [self.previewCanvas.window.screen deviceDescription];
    NSInteger screenID = [[screenDescription objectForKey:@"NSScreenNumber"] integerValue];
    NSSize pixelSize = [[screenDescription objectForKey:@"NSDeviceSize"] sizeValue];
    CGSize displaySize = CGDisplayScreenSize((CGDirectDisplayID)screenID); // Returns size in mm
    displaySize.width *= MILLIMETERS_TO_POINTS_FACTOR; // So convert into points
    CGFloat factor = pixelSize.width / displaySize.width; // (Shouldn't matter whether you calculate the factor by width or by height)
    [self.previewCanvas setScaleFactor:factor];
}

Is there a way to improve on this? Apple must be doing something at least slightly different to achieve virtually perfect results.

-António

-----------------------------------------
Forgiveness is not an occasional act;
it is a permanent attitude.

--Martin Luther King, Jr
-----------------------------------------

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Prev by Date: Re: Problem saving document with my doc icon
  • Next by Date: Advanced Techniques
  • Previous by thread: Re: Cocoa-dev Digest, Vol 10, Issue 425
  • Next by thread: Advanced Techniques
  • Index(es):
    • Date
    • Thread