当我在draw
这两个方面有所不同时,我不明白。text
PDF
truncate
specific width
第一个:
NSString *strText12 = @"HASDHADH skjdfhhs HKSJDHF.;; []'.hfkjhsfS SDHJHFSH jsfsjdfsn eiwj NJSDSJDF SDLKJJ sfkjsj wreoiwuowu 87243 7298 72jsdj h@#$$$!@$$";
if (strText12.length > 110 ) {
strText12 = [strText12 substringToIndex:110];
strText12 = [strText12 stringByAppendingFormat:@"...."];
}
CGContextSelectFont (aCgPDFContextRef, "Helvetica", 12, kCGEncodingMacRoman);
CGContextSetTextDrawingMode (aCgPDFContextRef, kCGTextFill);
CGContextSetRGBFillColor (aCgPDFContextRef, 0, 0, 0, 1);
const char *text1 = [strText12 UTF8String];
CGContextShowTextAtPoint (aCgPDFContextRef, 10,50.0, text1, strlen(text1));
第二个:
NSString *strText = @"hasdhadh skjdfhhs hksjdhf.;; []'.hfkjhsfs sdhjhfsh jsfsjdfsn eiwj njsdsjdf sdlkjj sfkjsj wreoiwuowu 87243 7298 72jsdj h@#$$$!@$$";
if (strText.length > 110 ) {
strText = [strText substringToIndex:110];
strText = [strText stringByAppendingFormat:@"...."];
}
CGContextSelectFont (aCgPDFContextRef, "Helvetica", 12, kCGEncodingMacRoman);
CGContextSetTextDrawingMode (aCgPDFContextRef, kCGTextFill);
CGContextSetRGBFillColor (aCgPDFContextRef, 0, 0, 0, 1);
const char *text = [strText UTF8String];
CGContextShowTextAtPoint (aCgPDFContextRef, 10,10.0, text, strlen(text));
结果为 PDF:
编辑:即使使用CoreText
result
is same
。