2012-09-14 3 views
0

내 PDF 리더는이 enter image description herePDF 리더, 얇은 흰색 선

같은 얇은 흰색 선을 표시하지만이 파일은 여기, Acrobat Reader가없고 흰색 라인에 잘 작동 난 내 pdf 파일을 처리하는 방법입니다

CGRect contentRect = CGRectMake(0, 0, width, height); 
CGContextRef context = CGBitmapContextCreate(NULL, 
              width, 
              height, 
              8,      /* bits per component*/ 
              width * 4,  /* bytes per row */ 
              colorSpace, 
              kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big); 

CGColorSpaceRelease(colorSpace); 
CGContextSaveGState(context); 
CGContextClipToRect(context, CGRectMake(0, 0, width, height)); 

// First fill the background with white. 
CGContextSetRGBFillColor(context, 1.0,1.0,1.0,1.0); 
CGContextFillRect(context,contentRect); 
CGContextSetInterpolationQuality(context, kCGInterpolationHigh); 
CGContextSetRenderingIntent(context, kCGRenderingIntentDefault); 

CGContextDrawPDFPage(context,page); 
CGImageRef image = CGBitmapContextCreateImage(context); 
CGContextRestoreGState(context); 
CGContextRelease(context); 

이 문제를 해결하려면 내 코드를 업데이트하거나 PDF 파일에 어떤 작업을 수행해야합니까?

답변

1
-(void)openPDfFile:(CGPDFDocumentRef)pdf 

{
// 우리가 페이지 = CGPDFDocumentGetPage (PDF, pageNumer)를 그리기 할 PDF 페이지를 얻으십시오; CGPDFPageRetain (page);

// determine the size of the PDF page 
CGRect pageRect = CGPDFPageGetBoxRect(page, kCGPDFCropBox); 
pdfScale = self.frame.size.height/pageRect.size.height; 
pageRect.size = CGSizeMake(pageRect.size.width*pdfScale, pageRect.size.height*pdfScale); 


// Create a low res image representation of the PDF page to display before the TiledPDFView 
// renders its content. 
UIGraphicsBeginImageContext(pageRect.size); 

CGContextRef context = UIGraphicsGetCurrentContext(); 

// First fill the background with white. 
CGContextSetRGBFillColor(context, 1.0,1.0,1.0,1.0); 
CGContextFillRect(context,pageRect); 

CGContextSaveGState(context); 
// Flip the context so that the PDF page is rendered 
// right side up. 
CGContextTranslateCTM(context, 0.0, pageRect.size.height); 
CGContextScaleCTM(context, 1.0, -1.0); 

// Scale the context so that the PDF page is rendered 
// at the correct size for the zoom level. 
CGContextScaleCTM(context, pdfScale,pdfScale); 
CGContextDrawPDFPage(context, page); 
CGContextRestoreGState(context); 

UIImage *backgroundImage = UIGraphicsGetImageFromCurrentImageContext(); 

UIGraphicsEndImageContext(); 

backgroundImageView = [[UIImageView alloc] initWithImage:backgroundImage]; 
backgroundImageView.frame = pageRect; 
backgroundImageView.contentMode = UIViewContentModeScaleAspectFit; 
[self addSubview:backgroundImageView]; 
[self sendSubviewToBack:backgroundImageView]; 

[self createPage:pageRect]; 

}

- (무효) createPage : (CGRect) pageRect { //는 PDF 페이지의 크기에 따라 TiledPDFView를 만들고 뷰에 맞게 그것을 확장 할 수 있습니다. pdfView = [[TiledPDFView alloc] initWithFrame : pageRect andScale : pdfScale]; [pdfView setPage : 페이지];

self.frame = pdfView.frame; 

[self addSubview:pdfView]; 

}

는이 방법을 시도!

1

이 내 사건에 도움을했다

CGContextSetInterpolationQuality(context, kCGInterpolationHigh); 
CGContextSetShouldAntialias(context, NO); // solves the problem with white lines