【发布时间】:2018-05-01 09:53:28
【问题描述】:
有没有人使用过将图像编码为 ccitt 的 PDF。 我使用 Xamarin,几乎所有的 pdf 似乎都可以工作。但是这种编码似乎很困难。该应用程序适用于 iOS。 页面大小正确但完全空白。
var pageRect = _page.GetBoxRect(CGPDFBox.Media);
pageRect.Size = new CGSize(pageRect.Size.Width, pageRect.Size.Height);
//pageRect.Origin = CGPointZero;
UIGraphics.BeginImageContext(pageRect.Size);
CGContext context = UIGraphics.GetCurrentContext();
//White BG
context.SetFillColor(1.0f, 1.0f, 1.0f, 1.0f);
context.FillRect(pageRect);
context.SaveState();
// Next 3 lines makes the rotations so that the page look in the right direction
context.TranslateCTM(0.0f, pageRect.Size.Height);
context.ScaleCTM(1.0f, -1.0f);
CGAffineTransform transform = _page.GetDrawingTransform(CGPDFBox.Media, pageRect, 0, true);
context.ConcatCTM(transform);
context.DrawPDFPage(_page);
context.RestoreState();
UIImage img = UIGraphics.GetImageFromCurrentImageContext();
UIGraphics.EndImageContext();
return img;
_page 是CGPDFPage 对象。
或者有人有从 PDF 文件中获取图像的 sn-p 吗? DrawPDFPage 是我认为无法处理此 pdf 的问题。 swift或c中的片段没问题
更新
我在我的应用程序中默认使用CATiledLayer。这将在部分(图块)中呈现 pdf,因此大 pdf 将显示部分而不是等待很长时间。
我发现当设置编码时,上面的代码会起作用,因为它会先渲染完整的pdf然后显示在屏幕上。
CATiledLayer 在这种情况下不起作用并显示空/空白页面。 我现在的搜索是寻找CGPDFDocument 或CGPDFPage 将返回我的元数据以便我能够查看编码的方式。 有人体验过吗?
【问题讨论】:
-
@ColeXia-MSFT 感谢您的建议。但是,这不起作用,因为它与上述相同。整个页面的绘图一次可以正确使用编码,但不能部分(图块)。你知道如何获取 pdf 页面的元数据吗?