1

I have a NSTextView contain table of data, and i override the drawPageBorderWithSize: method to draw page footer (page number) and page header contain a page title, every thing work ok when i use NSPrintOperation to display a print panel.

but i need to display the preview in my window (not that one in print panel), to do that i tried to export my view to PDF data like following:

    NSMutableData *pdfData = [[NSMutableData alloc]init];
NSPrintOperation *pdfOperation = [NSPrintOperation PDFOperationWithView:printView insideRect:NSMakeRect(0, 0, 600, 900) toData:pdfData printInfo:myPrintInfo];
[pdfOperation runOperation];

PDFDocument *pdfDocument = [[PDFDocument alloc]initWithData:pdfData];
[pdfDocument writeToFile:@"/my directory/Test.pdf"];

But the this PDF file show only the table, it doesn't show the header and footer i made using drawPageBorderWithSize, also there is no margins as i mad in myPrintInfo, and as i said all of that has appeared in print panel!!

also i got this error:

Assertion failed: (s->stack->next != NULL), function CGGStackRestore, file Context/CGGStack.c, line 77.

Why NSPrintOperation to PDF doisn't show every thing in my NSTextView??!!

Nayef
  • 463
  • 5
  • 13

1 Answers1

0

A bit late to the game but I just found your question.

The method drawPageBorderWithSize: is not called in that case. Draw everything in drawRect: instead.

Mike Lischke
  • 48,925
  • 16
  • 119
  • 181