2012-08-13 64 views
1

我想在iOS中生成的pdf中插入隐形文本。如何才能做到这一点?iOS中的隐形PDF文本

这是我如何在此刻产生PDF:

- (void) generatePdfWithFilePath: (NSString *)thefilePath words:(NSString *)string 
{ 
    UIGraphicsBeginPDFContextToFile(thefilePath, CGRectZero, nil); 

    UIGraphicsBeginPDFPageWithInfo(CGRectMake(0, 0, 612, 792), nil); 

    [self drawText:string]; 


    // Close the PDF context and write the contents out. 
    UIGraphicsEndPDFContext(); 
} 

回答

0

在PDF源代码,隐形文字可以使用文本呈现模式3被写入(“不能填补也不行程字形的形状”)。这就是OCR如何插入的文本转换成PDF页面基本上只包含扫描图像的:

3 Tr 

其他文本渲染模式的显示形式在PDF源代码:

  • 0 Tr(填入文字)
  • 1 Tr(行程文本)
  • 2 Tr(填充,然后行程文本)
  • 4 Tr(填入文字和添加到路径裁剪)
  • 5 Tr(中风文字并添加到路径裁剪)

你得找出你自己如何指示您的PDF生成库使用文本渲染模式3,虽然。

也看到这个答案(超级用户):"PDF has an extra blank in all words after running through Ghostscript"

注:这个 '无形' 的文字仍然会选择;用户仍然可以复制'n'粘贴;屏幕阅读器可以朗读;文本提取工具可以提取它; pdftotext可以将其转换为文本文件...