使用CoreGraphics创建多页PDF文件在控制台上显示错误

时间:2016-09-26 05:38:20

标签: ios objective-c core-graphics

我在创建多页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

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

2 个答案:

答案 0 :(得分:1)

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

我将其追溯到此代码段


    NSString* pgStr = [some text];        
    UIFont* theFont = [some font];

    NSMutableParagraphStyle * paragraphStyle = [[NSMutableParagraphStyle defaultParagraphStyle] mutableCopy];
    paragraphStyle.lineBreakMode = NSLineBreakByWordWrapping;
    paragraphStyle.alignment = NSTextAlignmentCenter;

    NSDictionary * attributes = @{NSFontAttributeName:theFont, NSParagraphStyleAttributeName:paragraphStyle
                                          };

    // ERROR        
    [pgStr drawInRect:[some frame] withAttributes:attributes];

要修复它,请为段落样式引入行高:


    paragraphStyle.minimumLineHeight = theFont.pointSize;
    paragraphStyle.maximumLineHeight = theFont.pointSize;

答案 1 :(得分:0)

这是一个错误 -

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