PDFView printWithInfo:autoRotate: 失败 [英] PDFView printWithInfo:autoRotate: fails

查看:49
本文介绍了PDFView printWithInfo:autoRotate: 失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试打印我从一系列图像构建的 PDFDocument.万一重要,我正在从 Mozilla 插件中完成所有这些.

I'm trying to print a PDFDocument that I am constructing from a series of images. In case it matters, I'm doing all of this from within a Mozilla plugin.

我创建了 PDFDocument,并将其放入 PDFView,然后调用

I create the PDFDocument, and put it into a PDFView, then I call

[printView printWithInfo: [NSPrintInfo sharedPrintInfo] autoRotate: YES];

打印对话框出现(作为一个单独的窗口,而不是面板.我假设它来自于 Mozilla 窗口内,所以我不太担心.对话框显示我的文档,我可以翻页正确地通过它,一切看起来都很好.

The print dialog comes up (as a separate window, instead of panel. I assume that that comes from being inside a mozilla window, so I wasn't too worried about it. The dialog shows my document, and I can page through it correctly, and everything looks good.

但是,当我点击打印"时,带有布局"等的下拉列表变为空,其下的视图变为空.窗口不会消失,文档也不会打印.点击取消完全相同.我唯一能做的就是强制退出 Mozilla.

However, when I hit "Print" the dropdown with "Layout" etc becomes empty, and the view under that becomes empty. The window doesn't disappear, and the document doesn't print. Hitting Cancel does exactly the same thing. The only thing I can do then is force-quit Mozillla.

我的程序基于 PDFKitLinker2 来自苹果开发网站,该程序有效.但我看不出它和我的版本之间有任何显着差异.

I based the program off of PDFKitLinker2 from the apple dev site, and that program works. But I can't see any significant differences between it and my version.

有什么关于去哪里看的建议吗?

Any suggestions on where to look?

谢谢.

是的,我知道这几乎是 Printing Off-screen PDFViews 但这从来没有得到足够的答案......(直到刚才我才注意到它......)

Yes, I know that this is pretty much an exact duplicate of Printing Off-screen PDFViews but that never got a sufficient answer... (And I didn't notice it until just now...)

推荐答案

听起来您在这里遇到了内存管理问题.您是否检查了控制台日志以查看是否有异常被抛出?您如何创建 PDFView?

Sounds like you have a memory management issue here. Have you checked the console log to see if there's an exception being thrown? How are you creating your PDFView?

但为什么不这样做 WebKit 是吗?

But why not do it the way WebKit does it?

具体来说,在PDFDocument

@interface PDFDocument (PDFSecretsIKnowViaWebKit)
- (NSPrintOperation *)getPrintOperationForPrintInfo:(NSPrintInfo *)printInfo autoRotate:(BOOL)doRotate;
@end

然后,当您想打印 PDFDocument 时,只需从中获取一个 NSPrintOperation 并运行它.

Then when you want to print your PDFDocument simply get an NSPrintOperation from it and run it.

NSPrintOperation *op = [myPDFDoc getPrintOperationForPrintInfo:info autoRotate:YES];
[op runOperation];
// [op runOperationModalForWindow:delegate:didRunSelector:contextInfo:] if you have a window to attach it to

这篇关于PDFView printWithInfo:autoRotate: 失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆