Re: No-frills print to label printer help please
Re: No-frills print to label printer help please
- Subject: Re: No-frills print to label printer help please
- From: "Boaz Stuller" <email@hidden>
- Date: Mon, 26 May 2008 10:35:50 -0400
I don't really remember how I chose the view's size, but I think I set it up
in IB to be big enough for the label size they were using. I just ran it,
and it doesn't scale the image up, only down, so presumably I just made it
big enough in Interface Builder. I'd guess that scaling the view to the
page bounds before each print would accomplish what you're looking for:
double ScaleViewToPrintPageSize(NSView* labelView, NSPrintInfo* printInfo)
{
NSRect pageRect = [printInfo imageablePageBounds];
NSRect viewRect = [labelView frame];
double scaleFactor = MIN(NSWidth(pageRect) / NSWidth(viewRect),
NSHeight(pageRect) / NSHeight(viewRect));
[labelView scaleUnitSquareToSize:NSMakeSize(scaleFactor, scaleFactor)];
[labelView setFrameSize:NSMakeSize(NSWidth(viewRect) * scaleFactor,
NSHeight(viewRect) * scaleFactor)];
return scaleFactor;
}
I haven't tested that, but that should scale up your view to approximately
the page size. OTOH, if you know the label size in advance you can just
multiply the inches by 72 to get the size your view needs to be able to fill
the label and just create it at least that size. For a 2.34 x 4 label, that
would be a label 169 x 288, but as long as you preserved the aspect ratio,
you could make it any amount bigger and still be fine if you use
NSFitPagination.
Best wishes,
Bo
On Mon, May 26, 2008 at 1:06 AM, Rick Mann <email@hidden> wrote:
>
> On May 25, 2008, at 20:20:38, Boaz Stuller wrote:
>
> I wrote almost this exact same program about 2 years ago. Looking back at
>> the code, here's what I did:
>>
>
>
> Thanks Boaz. Did you also override the pagination stuff? What size is your
> view, just some arbitrary size in IB, or do you adjust it based on the
> NSPrintInfo values?
>
> --
> Rick
>
>
_______________________________________________
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