大家好我嘗試了很多方式來打印PDF與PDF書的大小。我也搜索了許多鏈接和許多代碼,如蘋果代碼,github和許多這樣的類型的網站,但沒有用。這個問題是重複的許多問題和答案,但我仍然沒有得到確切的result.my代碼看起來像這樣在整個屏幕上呈現pdf的問題pdf
(無效)drawLayer:(CALayer的*)層inContext的:(CGContextRef)CTX { (UIInterfaceOrientationIsPortrait([self interfaceOrientation])){ layer.backgroundColor = [UIColor blackColor]; myPageRef = CGPDFDocumentGetPage(myDocumentRef,c);
CGSize pageSize = [kbDataSource pageSize]; GLogInfo(@"the page ize we are getting in draw layer is %@ ",NSStringFromCGSize(pageSize)); //CGContextSaveGState(ctx); CGSize aspectFitSize = [self getPageFitSizeOfSize:pageSize inSize:CGSizeMake(self.view.bounds.size.width, self.view.bounds.size.height- __TOP_BRANDING_BAR_HEIGHT)]; CGContextSetRGBFillColor(ctx, 1.0, 1.0, 1.0, 1.0); CGContextFillRect(ctx, CGContextGetClipBoundingBox(ctx)); GLogDebug(@"aspect fitsize of image to %@", NSStringFromCGSize(aspectFitSize)); NSLog(@"layer bounds are:%@ %@ ",NSStringFromCGSize(layer.bounds.size),NSStringFromCGPoint(layer.bounds.origin)); NSLog(@"page size of the book is:%@",NSStringFromCGSize(pageSize)); CGFloat aspectRatio=pageSize.width/pageSize.height; CGRect cropBox = CGPDFPageGetBoxRect(myPageRef, kCGPDFCropBox); CGRect targetRect = layer.bounds; CGFloat xScale = targetRect.size.width/cropBox.size.width; CGFloat yScale = (targetRect.size.height-41)/cropBox.size.height; CGFloat scaleToApply = (xScale < yScale) ? xScale : yScale; CGContextTranslateCTM(ctx, 0.0, -41+layer.bounds.size.height); CGContextScaleCTM(ctx, 1.0, -1.0); NSLog(@"the crop box values are %@",NSStringFromCGRect(cropBox)); NSLog(@"the crop box values are %f",cropBox.origin.x); NSLog(@"the scaleToApply is %f",scaleToApply); NSLog(@"the view bounds are %@",[self.view description]); if (scaleToApply == yScale) CGContextConcatCTM(ctx, CGAffineTransformMakeTranslation(-100, -150)); else CGContextConcatCTM(ctx, CGAffineTransformMakeTranslation(-180, -260)); CGContextConcatCTM(ctx, CGAffineTransformMakeScale(scaleToApply, scaleToApply)); CGContextConcatCTM(ctx, CGPDFPageGetDrawingTransform(myPageRef, kCGPDFCropBox, layer.bounds, 0, true)); CGContextSetInterpolationQuality(ctx, kCGInterpolationHigh); CGContextSetRenderingIntent(ctx, kCGRenderingIntentDefault); CGContextDrawPDFPage(ctx, myPageRef);
}
我粘貼所有i的drawlayer試過的代碼。我給了很多隨機數字,以適應整個頁面的頁面,最後我只獲得了八本書(pdf)。
我的目標是打印任何PDF與整個ipad屏幕覆蓋。 我的結果是隻有幾個pdfs.cf任何人告訴我爲什麼發生的確切原因,並告訴我確切的代碼打印PDF到整個ipad屏幕。
謝謝大家。
嗨Altealice,我嘗試了上面提到的內容,但是它對我的解決方案沒有任何幫助。我發佈了我的新代碼。 – user568065 2011-01-10 06:58:26
當您使用我建議的代碼時會發生什麼? – Altealice 2011-01-10 08:12:18