1
나는 이와 비슷한 코드를 사용하여 cgcontext로 pdf를 생성합니다. 그것은 하나의 페이지로 PDF 파일을 만듭니다. 내 PDF를위한 두 번째 페이지를 만드는 데 필요한 것은 무엇입니까?cgcontext에 의해 생성 된 pdf에 페이지 추가하기
즉, 두 페이지에 걸쳐 콘텐츠를 홍보하고 싶습니다. 어쨌든 이걸 할거야?
// Make the pdf A4 size.
CGRect sizeOfA4 = CGRectMake(0, 0, 595, 842);
CGContextRef pdfContext = [self createPDFContext:sizeOfA4 path:(CFStringRef)writableDBPath];
CGContextBeginPage (pdfContext,nil); // 6
// push the matrix
CGContextSaveGState(pdfContext);
// turn PDF upsidedown
CGAffineTransform transform = CGAffineTransformIdentity;
// translates the cooridinate system by the height of the view.
transform = CGAffineTransformMakeTranslation(xPos, aUIView.bounds.size.height+yPos);
// scales existing transform
transform = CGAffineTransformScale(transform, 1.0*scale, -1.0*scale);
CGContextConcatCTM(pdfContext, transform);
// Draw view into PDF
// Is renderInContext deprecated? Something to look into.
[aUIView.layer renderInContext:pdfContext];
// pop the matrix
CGContextRestoreGState(pdfContext);
// turn PDF upsidedown
CGAffineTransform transformB = CGAffineTransformIdentity;
// translates the cooridinate system by the height of the view.
transformB = CGAffineTransformMakeTranslation(0.0, 842);
// scales existing transform
transformB = CGAffineTransformScale(transformB, 1.0, -1.0);
CGContextConcatCTM(pdfContext, transformB);
CGContextSelectFont (pdfContext, "Helvetica", 14, kCGEncodingMacRoman);
CGContextSetTextDrawingMode (pdfContext, kCGTextFill);
CGContextSetRGBFillColor (pdfContext, 0, 0, 0, 1);
CGContextSetTextMatrix(pdfContext, CGAffineTransformMake(1.0,0.0, 0.0, -1.0, 0.0, 0.0));
// loop through array of dictionaries of texts
for (id object in arrayOfTexts) {
NSString *textNSString = [object objectForKey:@"text"];
const unsigned char *text = (const unsigned char *) [textNSString UTF8String];
float x = [[object objectForKey:@"x"] floatValue];
float y = [[object objectForKey:@"y"] floatValue];
CGContextShowTextAtPoint (pdfContext, x, y, text, strlen(text));
}
CGContextEndPage (pdfContext); // 8
CGContextRelease (pdfContext);
이 문제가 해결 되었습니까? 그렇다면 대답을 게시하십시오. – Hitesh