大家好我尝试了很多方式来打印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