6

I am having a problem in creating the multi page PDF. I am using NSMutableData for storing the PDF data. When I am drawing a new page using the following code

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

It shows me following error on console

<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.

Please can someone help me to resolve the error.

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

it says that core graphics logs are getting confusing values but i am not getting a resolution on the error Thank You.

Shaniraaj
  • 59
  • 9
  • I am also facing the same issue have you found the solution? – Sanju Nov 22 '16 at 13:48
  • No,The error are minimized i.e.previously it was showing me many number of lines with the above error but when i decreased the color shades for drawing the pdf the line lines are displaying less than 10,I think the issue is related with the color used for drawing the PDF. – Shaniraaj Nov 23 '16 at 11:23
  • I didnt use any color shades still in console shows the above errors. In this link question is my code Can you please have look once: http://stackoverflow.com/questions/37461231/cant-create-pdf-and-print-more-than-60-pages-memory-raises-crashes – Sanju Nov 23 '16 at 11:31

2 Answers2

1

I could reproduce the error and apparently fix it. I have an app on the App Store since 2013. The app creates some PDF files and the error showed for the first time in iOS 10.

I traced it to this snippet


    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];

To fix it, introduce line heights to the paragraph style:


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

SuanMei
  • 51
  • 4
  • i am still facing the errors even after adding above two lines. I getting the error exactly at same line i.e.when i am drawing the text to PDF – Shaniraaj Dec 09 '16 at 09:10
0

It's a bug -

Open Radar Link: http://www.openradar.me/28250871

Igor
  • 12,165
  • 4
  • 57
  • 73