我有一个pdf生成项目,它包含一些文本和一个已经存储在数据库中的图像,我想预览并发送pdf生成的,只有文本数据时一切正常。缩小pdf大小 - 目标c
如果我们的数据中存在图像,则会出现问题。邮件接收 大小为10MB的PDF或以上,即使它具有大小为1MB图像或below.It在simulator.My代码来绘制图像工作正常显示如下:
UIImage *plotImage=[[UIImage alloc]initWithContentsOfFile:[localPictureArray objectAtIndex:i]];
CGSize imageSize=plotImage.size;
CGFloat scaleFactor = 1.0;
if (imageSize.height>(maxHeight-currentPageY) || imageSize.width>maxWidth)
{
UIGraphicsBeginPDFPageWithInfo(CGRectMake(0, 0, kDefaultPageWidth, kDefaultPageHeight), nil);
currentPageY = kMargin;
if (!((scaleFactor = (maxWidth/imageSize.width)) > ((maxHeight-currentPageY)/imageSize.height)))
{
scaleFactor = (maxHeight-currentPageY) /imageSize.height;
// scale to fit heigth.
}
CGRect rect = CGRectMake(kMargin,currentPageY,
imageSize.width * scaleFactor, imageSize.height * scaleFactor);
//Draw the image into the rect
[plotImage drawInRect:rect];
}
else
{
plotImage drawInRect:normal size)];//Normal size we need
NSLog(@"%@",NSStringFromCGSize(plotImage.size));
}
由于IAM起动机IAM努力解决它。
仍然没有解决..任何人都可以帮助我! – 2013-03-06 08:06:21
你的其他人在它前面没有'}',是只有一个错字吗? – Manuel 2013-03-06 08:38:18
不,前面的else前面还没有关闭if:if(imageSize.height>(maxHeight-currentPageY)|| imageSize.width> maxWidth){'。不应该'else {'像这样:'} else {'? – Manuel 2013-03-06 08:47:45