【发布时间】:2014-09-14 22:55:48
【问题描述】:
我有一个 NSTextView 包含数据表,我重写了 drawPageBorderWithSize: 方法来绘制页脚(页码)和页眉包含页标题,当我使用 NSPrintOperation 显示打印面板时,一切正常。
但我需要在我的窗口中显示预览(不是打印面板中的那个),为此我尝试将我的视图导出为 PDF 数据,如下所示:
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"];
但是这个 PDF 文件只显示了表格,它没有显示我使用 drawPageBorderWithSize 制作的页眉和页脚,而且我在 myPrintInfo 中也没有边距,正如我所说的,所有这些都出现在打印面板中!!
我也收到了这个错误:
断言失败:(s->stack->next != NULL),函数 CGGStackRestore,文件 Context/CGGStack.c,第 77 行。
为什么 NSPrintOperation to PDF 没有显示我的 NSTextView 中的所有内容??!!
【问题讨论】: