使用 Quartz 在 iOS 上获取 PDF GoTo 操作
我是苹果 PDF 核心图形的新手。我开发一个应用程序来显示带有链接/操作的 PDF,该链接/操作将转到页面 x/y。我找到的第一个代码/帮助是这里。但该代码用于网站的外部 URL。在 Adobe.com 的 pdf 参考文档中,我发现我必须使用“GoTo”操作。我已经尝试了所有 3 种类型(对象、名称和字节字符串),但它不起作用。谁能给我提示,我做错了什么?
for (unsigned i = 0; i < arrayCount; ++i) {
CGPDFObjectRef aDictObj;
if (!CGPDFArrayGetObject(outputArray, i, &aDictObj)) {
return;
} // END if
CGPDFDictionaryRef annotDict;
if(!CGPDFObjectGetValue(aDictObj, kCGPDFObjectTypeDictionary, &annotDict)) {
return;
} // END if
CGPDFDictionaryRef aDict;
if(!CGPDFDictionaryGetDictionary(annotDict, "A", &aDict)) {
return;
} // END if
const char *gotoNameRef;
CGPDFArrayRef gotoArray;
if (CGPDFDictionaryGetArray(aDict, "D", &gotoArray)) {
if (!CGPDFArrayGetName(gotoArray, 0, &gotoNameRef)) {
return;
}
} else {
return;
} // END if
int gotoCounter = CGPDFArrayGetCount(gotoArray);
CGPDFArrayRef rectArray;
if(!CGPDFDictionaryGetArray(annotDict, "Rect", &rectArray)) {
return;
} // END if
int arrayCount = CGPDFArrayGetCount( rectArray );
CGPDFReal coords[4];
for( int k = 0; k < arrayCount; ++k ) {
CGPDFObjectRef rectObj;
if(!CGPDFArrayGetObject(rectArray, k, &rectObj)) {
return;
} // END if
CGPDFReal coord;
if(!CGPDFObjectGetValue(rectObj, kCGPDFObjectTypeReal, &coord)) {
return;
} // END if
coords[k] = coord;
} // END for
感谢您的任何帮助。
i´m new to apple´s core graphic for PDF. I developing an app to display a PDF with links/actions which will go to the page x/y. The first code/help i found was here. But that code is for external URLs to websites. In the pdf ref doc from Adobe.com i found out, that i have to use the "GoTo" action. I´ve tried all 3 types (object, name and byte string) but it doesn´t work. Can anyone get me a hint, what i´m doing wrong?
for (unsigned i = 0; i < arrayCount; ++i) {
CGPDFObjectRef aDictObj;
if (!CGPDFArrayGetObject(outputArray, i, &aDictObj)) {
return;
} // END if
CGPDFDictionaryRef annotDict;
if(!CGPDFObjectGetValue(aDictObj, kCGPDFObjectTypeDictionary, &annotDict)) {
return;
} // END if
CGPDFDictionaryRef aDict;
if(!CGPDFDictionaryGetDictionary(annotDict, "A", &aDict)) {
return;
} // END if
const char *gotoNameRef;
CGPDFArrayRef gotoArray;
if (CGPDFDictionaryGetArray(aDict, "D", &gotoArray)) {
if (!CGPDFArrayGetName(gotoArray, 0, &gotoNameRef)) {
return;
}
} else {
return;
} // END if
int gotoCounter = CGPDFArrayGetCount(gotoArray);
CGPDFArrayRef rectArray;
if(!CGPDFDictionaryGetArray(annotDict, "Rect", &rectArray)) {
return;
} // END if
int arrayCount = CGPDFArrayGetCount( rectArray );
CGPDFReal coords[4];
for( int k = 0; k < arrayCount; ++k ) {
CGPDFObjectRef rectObj;
if(!CGPDFArrayGetObject(rectArray, k, &rectObj)) {
return;
} // END if
CGPDFReal coord;
if(!CGPDFObjectGetValue(rectObj, kCGPDFObjectTypeReal, &coord)) {
return;
} // END if
coords[k] = coord;
} // END for
Thanks for any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里有一个 PDF 阅读器的源代码:
https://github.com/vfr/reader
它是在 ObjectiveC 上并且包含你需要的一切。
There is a PDF reader in source available here:
https://github.com/vfr/reader
It is on ObjectiveC and contains everything you need.