0
我使用從我的Core Data圖中輸出的數據即時生成PDF文檔,但事實證明這非常困難。使用Core Data中的CGRect繪製UIImage
我使用的素材資源庫以獲取圖像的文件路徑從核心數據圖的使用以下:
NSURL *url = [[NSURL alloc] initWithString:bird.photo];
ALAssetsLibrary* library = [[ALAssetsLibrary alloc] init];
[library assetForURL:url resultBlock:^(ALAsset *asset) {
_pdfBirdmage = [UIImage imageWithCGImage:[[asset defaultRepresentation] fullResolutionImage]];
} failureBlock:^(NSError *error) {
NSLog(@"Couldn't load asset %@ => %@", error, [error localizedDescription]);
}];
,這是顯示圖像是爲以下幾點:
birdphotoview = <UIImage: 0x1caac0>
很明顯,我想這是一種圖像格式,如PNG或JPG,以便將其寫入PDF文檔,使用下面的代碼:
[_pdfBirdImage drawInRect:CGRectMake((pageSize.width - _pdfBirdImage.size.width/2)/2, 350, _pdfBirdImage.size.width/2, _pdfBirdImage.size.height/2)];
但是,這不是打印任何東西的pdf。
任何幫助將是輝煌的。
圖像是否正確?你是否試圖在圖像視圖中顯示它?您的pdf繪圖環境是否正確? – cocoakomali 2012-03-29 17:19:32
是的,是的,是的..更嚴重的說明,我認爲UIImage必須是.png圖像。基本上,我需要將我的轉換爲.png – jcrowson 2012-03-29 19:01:13
要執行轉換使用UIImagePNGRepresentation(UIImage *圖像)函數,它返回一個NSData對象。將其寫入文件並使用該圖像。 – cocoakomali 2012-03-30 03:34:44