我有一個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