안녕하세요. pdf book.i의 크기에 따라 여러 가지 방법으로 PDF를 인쇄 해 보았습니다. 많은 링크와 사과 코드, github 및 많은 코드와 같은 많은 코드를 검색했습니다. 사이트 유형은 있지만 사용하지 마십시오. 이 질문은 많은 질문과 답변의 중복하지만 여전히 나는 정확한 result.my 코드는이pdf의 전체 화면에서 렌더링하는 데 문제가 있습니다
(무효) drawLayer처럼 찾고되지 않았다 (의 CALayer *) 레이어 inContext : (CGContextRef) CTX {
if (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);
은}
난 내가 drawlayer에서 재판을 모든 코드를 붙여 넣습니다. 마침내 나는 8 권의 책 (pdfs)만을 얻었습니다.
내 목표는 전체 ipad 화면을 덮고있는 모든 PDF를 인쇄하는 것입니다. 내 결과는 단지 몇 pdfs.can에 대해서만 점점 더 정확한 이유를 알려주고 정확한 코드가 ipad의 전체 화면에 PDF를 인쇄하도록 알려줍니다.
감사합니다.
안녕 Altealice, 내가 언급 한 위의 줄로 시도했지만 내 솔루션에 전혀 도움이되지 않습니다. 내 새로운 코드를 게시했습니다. – user568065
내가 제안한 코드를 사용하면 어떻게됩니까? – Altealice
동일한 문제가 모든 pdfs.some 렌더링에서 제대로 작동하지 않으며 일부 페이지가 전체 화면을 렌더링하지 않습니다. – user568065