• 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
Printing Problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Printing Problem


  • Subject: Printing Problem
  • From: Peter Hudson <email@hidden>
  • Date: Sun, 28 Jul 2013 23:09:34 +0100

All

I have assembled several pages of text as RTF in an offscreen NSTextView  -  outputTextView in the code below.

As the text was assembled in the view, I have marked the end of each page with  a  \page symbol in the RTF.

As I have added each piece of text into the view I have determined how many pages the completed document requires.



NSView *customView;
customView = [[[NSView  alloc] initWithFrame:NSMakeRect(0, 0,  paperSize.width,
                                                   paperSize.height * countPages)] autorelease];

        [customView setBounds:NSMakeRect(0, 0, paperSize.width,   paperSize.height * countPages)];



NSTextStorage *textStorage = [outputTextView textStorage];

NSLayoutManager *layoutManager = [[NSLayoutManager alloc] init];

[textStorage addLayoutManager:layoutManager];



unsigned i;
for (i = 1; i <= countPages; i++)
{

	NSTextContainer *textContainer = [[NSTextContainer alloc] initWithContainerSize:
						NSMakeSize(printableArea.width, printableArea.height)];

	NSTextView *textView = [[NSTextView alloc] initWithFrame:
				NSMakeRect( LEFT_MARGIN,									      // x
				( BOTTOM_MARGIN +    (countPages - i) * (printableArea.height   + ( BOTTOM_MARGIN + TOP_MARGIN )) ),  // y
				printableArea.width,										      // width
				printableArea.height)										      // height
				textContainer:textContainer];


	[layoutManager addTextContainer:textContainer];
	[textContainer release];

	[customView addSubview:textView];
	[textView release];

}

[[outputTextView layoutManager]  invalidateLayoutForCharacterRange:NSMakeRange( 0, [[outputTextView  textStorage]  length] )
					isSoft:NO  actualCharacterRange:nil];



NSPrintOperation *printOp;

printOp = [NSPrintOperation  printOperationWithView:customView  printInfo:printInfo];

[printOp  setShowsPrintPanel:TRUE];

[printOp  runOperation];



I have checked carefully that the sizes of pages and print areas etc all make sense - and they do.


The problem I have is that when I run the print job,  the text drifts lower down each new page -
	by about an eigth of a page each new page.

Any suggestions appreciated !


Peter





_______________________________________________

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: Button on side menu not working
  • Next by Date: Re: UIScrollView to UIImage
  • Previous by thread: RE: Button on side menu not working
  • Next by thread: Exiting non-POSIX threads?
  • Index(es):
    • Date
    • Thread