24

QuartzDemoに基づいて、 CGPDFDocumentを使用して単純な PDF ビューアを作成しようとしています。
一般的なレンダリングがあります:

-(void)drawInContext:(CGContextRef)context
{
    // PDF page drawing expects a Lower-Left coordinate system, 
    // so we flip the coordinate system before we start drawing.
    CGContextTranslateCTM(context, 0.0, self.bounds.size.height);
    CGContextScaleCTM(context, 1.0, -1.0);

    // Grab the first PDF page
    CGPDFPageRef page = CGPDFDocumentGetPage(pdf, pageNumber);
    // We're about to modify the context CTM to draw the PDF page
    //  where we want it, so save the graphics state 
    // in case we want to do more drawing
    CGContextSaveGState(context);
    // CGPDFPageGetDrawingTransform provides an easy way 
    // to get the transform for a PDF page. It will scale down to fit, 
    // including any base rotations necessary to display the PDF page correctly. 
    CGAffineTransform pdfTransform = 
            CGPDFPageGetDrawingTransform(page, 
                    kCGPDFCropBox, self.bounds, 0, true);
    // And apply the transform.
    CGContextConcatCTM(context, pdfTransform);
    // Finally, we draw the page 
    // and restore the graphics state for further manipulations!
    CGContextDrawPDFPage(context, page);
    CGContextRestoreGState(context);
}

私が理解しているように、それは唯一の描画であるため、すべての構造ナビゲーションまたは発信リンクは手動で処理する必要があります (例: タッチ イベント)。

URL を設定したり、 URL で要素を作成したりする関数があります。

質問:特定の PDF ブロックから発信リンクの URL を取得する方法を教えてください。

ありがとうございました!

同様の質問:
iPhone/iPad
での PDF ハイパーリンク PDF ドキュメント (iPhone) でハイパーリンクにアクセスするにはどうすればよいですか?


iPhone SDK Dev GGroup macRumors
フォーラム
iPhone Dev SDK フォーラム
Dev Shed フォーラム
iphonedevbook.com についても同様です。

4

1 に答える 1

17

これは重要な質問です。そのため、簡単な答えが見つかりませんでした。解決策は次のとおりです。PDF ドキュメントを解析する必要があります。良いニュースは、これを可能にする機能が Apple によって提供されていることです。悪いニュースは、それらは手続き型であり、複雑な混乱です。

非常に大まかな擬似コードで:

  • CGPDFDocumentGetCatalog を使用して、PDF のカタログを取得します。
  • 探しているページのカタログの「pages」要素を調べます (はい、これは配列ではなく辞書であり、ネストされているため、この単純な操作はそれほど単純ではありません)。
  • CGPDFDictionaryGetArray を使用して "Annots" オブジェクトを取得するようになりました
  • 次に、注釈を反復処理して「リンク」オブジェクトを探す必要があります。

Adobe は、PDF 仕様を説明するドキュメントを公開しました。幸運を!

于 2010-09-28T00:27:05.287 に答える