2

私のアプリケーションでは、PDF リーダー (サーバーからの PDF) を表示し、すべてを別の PDF にコピーする必要があります。Readerを使用してPDFを表示しています。

ただし、PDF 内のテキストをフォーマットすることはできません。太字のテキストは、太字以外の別の狭いフォントで表示されます。解決策を教えてください。

繰り返しますが、執筆中は、Quartz を使用して PDF ドキュメントをディスクに保存しています。しかし、ここで私は同じ問題に直面しています。新しい PDF には、ソース PDF で使用されているフォント以外のフォントが表示されています。

以下のコードも試しました。それでも私は同じO / Pを取得しています。これで私を助けてください。イタリック/アンダーラインのような別のテキスト フォントではテストしていません。これらのフォントでも機能するはずです。

- (void) generatePdfWithFilePath: (NSString *)thefilePath {
  UIGraphicsBeginPDFContextToFile(thefilePath, CGRectZero, NULL);
  BOOL done = NO;

  do {
    //Start a new page.
    UIGraphicsBeginPDFPageWithInfo(CGRectMake(0, 0, pageSize.width, pageSize.height), nil);
    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"MyPdf" ofType:@"pdf"];
    CFURLRef url = (CFURLRef)[NSURL fileURLWithPath:filePath];
    CGPDFDocumentRef pdf = CGPDFDocumentCreateWithURL(url);
    CGPDFPageRef page = CGPDFDocumentGetPage(pdf, 1);
    CGRect paperSize = CGPDFPageGetBoxRect(CGPDFDocumentGetPage (pdf, 1), kCGPDFMediaBox);
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextTranslateCTM(context, 0, paperSize.size.height);
    CGContextScaleCTM(context, 1.0, -1.0); 
    CGContextDrawPDFPage(context, page);
    done = YES;
  } while (!done);

  UIGraphicsEndPDFContext();
}

ソース PDF が iOS デバイス以外のソースから生成された場合に発生しています。

4

1 に答える 1

0

A couple of thoughts:

  1. The font you're looking to display is not in any of the iOS devices, nor is it embedded in the PDF. Thus, it substitutes a font it thinks is similar.
  2. You don't have to use Reader to display a PDF, you can use a web view, the UIDocumentInteraction Controller, or CGPDFController. You might have more luck using one of these built-in displays, rather than Reader.
于 2012-08-14T17:35:01.513 に答える