简体   繁体   English

在iphone / ipad中从opengles上下文生成pdf

[英]Generate a pdf from opengles context in iphone/ipad

Hi am a noob at PDF generation and currently am displaying a 3d bar charts in my application in glview which is in side a uiview. 嗨,我是PDF生成专家,目前正在我的应用程序glview中显示3d条形图,它位于uiview的一边。 Now i want to generate a PDF document from the uiview which contains a text view and a glview. 现在,我想从uiview生成一个PDF文档,该文档包含一个文本视图和一个glview。 Am able to generate a PDF from text but where as GL View am unable to proceed.even i tried for a possibility over the net but unable to get any info regarding this.Can someone help me by providing the solution whether this can be possible or not.Thanks in Advance 能够从文本生成PDF,但是由于GL View无法进行。即使我尝试通过网络访问,但也无法获得任何有关此信息。有人可以通过提供解决方案来帮助我吗?不,谢谢

You can ask any UIView to give you an image (which might be a start) via something like: 您可以要求任何UIView通过以下方式为您提供图像(可能是一个开始):

- (UIImage *) imageRepresentation {
    // render myself (or more correctly, my layer) to an image
    UIGraphicsBeginImageContext(self.bounds.size);

    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetShouldSmoothFonts(context, false);
    CGContextSetShouldAntialias(context, false);

    [self drawLayer:self.layer inContext:context];
    [self.layer renderInContext:context];

    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    return image;
}

After that, you might be able to get a PDF representation of it, or investigate calls like CGPDFDocumentCreateWithURL to construct one yourself from the image. 在那之后,您也许可以得到它的PDF表示,或者研究诸如CGPDFDocumentCreateWithURL调用以从图像中构建自己。

You can use CoreGraphic's PDF-APIs to creating and drawing to a PDF. 您可以使用CoreGraphic的PDF-API创建和绘图为PDF。
See Apple's guide for more details. 有关更多详细信息,请参见Apple指南

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM