字符串拆分创建pdf?

时间:2015-03-03 10:38:56

标签: ios

我必须生成pdf文件。我的pdf文件页面大小是固定的。但是字符串(文本)是从pdf页面文件高度开始的高度。但是字符串只在页面中绘制而不是分割到下一页。

 float height = 40;
    CGRect rectFrame = CGRectMake(x, y, width-kMarginInset, height);
    CGContextSetRGBFillColor(currentContext, 0.0, 0.0, 0.0, 1.0);
    NSString *textToDraw =text;
    CGSize stringSize = [textToDraw sizeWithFont:font
                               constrainedToSize:CGSizeMake(width, 100000)
                                   lineBreakMode:NSLineBreakByWordWrapping];

    CGRect renderingRect = rectFrame;
    if (height<stringSize.height)
    {
        height=stringSize.height+height;
        renderingRect = CGRectMake(kBorderInset + kMarginInset, kBorderInset + kMarginInset + 50.0, pageSize.width - 2*kBorderInset - 2*kMarginInset, stringSize.height);
    }

    renderingRect.origin.y=rectFrame.origin.y+((height - stringSize.height)/2);
    renderingRect.size.height=height;
    renderingRect.origin.x+=kMarginInset;
    rectFrame.size.height=height+height*.5;

    [textToDraw drawInRect:renderingRect
                  withFont:font
             lineBreakMode:NSLineBreakByWordWrapping
                 alignment:NSTextAlignmentLeft];

    pdfCurrentPoint.x+=width;

请有人帮帮我吗?

0 个答案:

没有答案