【问题标题】:Creating Multipage PDF File using CoreGraphics shows error on console使用 CoreGraphics 创建多页 PDF 文件在控制台上显示错误
【发布时间】:2016-09-26 05:38:19
【问题描述】:

我在创建多页 PDF 时遇到问题。 我正在使用 NSMutableData 来存储 PDF 数据。 当我使用以下代码绘制新页面时

CGContextSetRGBFillColor(context, 0.0, 0.0, 0.0, 1.0);
**    Error Line   **

UIGraphicsBeginPDFPageWithInfo(CGRectMake(0, 0, 595, 841), nil);

[self drawPageAtIndex:self.numberOfPages+1 inRect:CGRectMake(0, 0, pageWidth, pageHeight)];
[self drawBorder];//draws Border to the page

它在控制台上显示以下错误

<Error>: replacing +/-infinity with -2147483648.
<Error>: replacing +/-infinity with 2147483647.
<Error>: replacing +/-infinity with -2147483648.
<Error>: replacing +/-infinity with 2147483647.
<Error>: replacing +/-infinity with -2147483648.
<Error>: replacing +/-infinity with 2147483647.
<Error>: replacing +/-infinity with -2147483648.
<Error>: replacing +/-infinity with 2147483647.

请有人帮我解决这个错误。

Here is the link which i reffered previously for the same error

它说核心图形日志的值令人困惑,但我没有得到错误的解决方案 谢谢。

【问题讨论】:

  • 我也遇到同样的问题你找到解决办法了吗?
  • 不,错误已最小化,即以前它向我显示了许多带有上述错误的行,但是当我减少绘制 pdf 的颜色阴影时,我认为线条显示少于 10该问题与用于绘制 PDF 的颜色有关。
  • 我没有在控制台中使用任何色调显示上述错误。在这个链接问题是我的代码你能看一次吗:stackoverflow.com/questions/37461231/…

标签: ios objective-c core-graphics


【解决方案1】:

我可以重现错误并明显修复它。自 2013 年以来,我在 App Store 上有一个应用程序。该应用程序会创建一些 PDF 文件,并且在 iOS 10 中首次显示错误。

我追踪到这个sn-p

NSString* pgStr = [一些文本]; UIFont* theFont = [一些字体]; NSMutableParagraphStyle * paragraphStyle = [[NSMutableParagraphStyle defaultParagraphStyle] mutableCopy]; 段落样式.lineBreakMode = NSLineBreakByWordWrapping; 段落样式.alignment = NSTextAlignmentCenter; NSDictionary * 属性 = @{NSFontAttributeName:theFont, NSParagraphStyleAttributeName:paragraphStyle }; // 错误 [pgStr drawInRect:[some frame] withAttributes:attributes];

要修复它,在段落样式中引入行高:

段落样式.minimumLineHeight = theFont.pointSize; 段落样式.maximumLineHeight = theFont.pointSize;

【讨论】:

  • 即使添加了以上两行,我仍然面临错误。我在同一行得到错误,即当我将文本绘制到 PDF 时
【解决方案2】:

这是一个错误 -

打开雷达链接:http://www.openradar.me/28250871

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-02-23
    • 2016-02-11
    • 2021-11-17
    • 1970-01-01
    • 1970-01-01
    • 2019-12-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多