2
在我的應用程序中,我必須顯示PDF閱讀器(來自服務器的PDF)並將所有內容複製到另一個PDF中。我正在使用Reader來顯示PDF。iOS中的PDF閱讀器和書寫器中的文本格式
但它無法格式化PDF中的文本。 粗體文本以粗體之外的某種不同的窄字體顯示。你能給我一個解決方案嗎?
同樣,在寫作時我使用的是Saving a PDF document to disk using Quartz。但在這裏我面臨着同樣的問題。新的PDF顯示的不是源PDF中使用的字體。
我也試過下面的代碼。我仍然得到相同的O/P。請幫我解決一下這個。我還沒有用斜體/下劃線等文字字體測試過。它也應該適用於這些字體。
- (void) generatePdfWithFilePath: (NSString *)thefilePath {
UIGraphicsBeginPDFContextToFile(thefilePath, CGRectZero, NULL);
BOOL done = NO;
do {
//Start a new page.
UIGraphicsBeginPDFPageWithInfo(CGRectMake(0, 0, pageSize.width, pageSize.height), nil);
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"MyPdf" ofType:@"pdf"];
CFURLRef url = (CFURLRef)[NSURL fileURLWithPath:filePath];
CGPDFDocumentRef pdf = CGPDFDocumentCreateWithURL(url);
CGPDFPageRef page = CGPDFDocumentGetPage(pdf, 1);
CGRect paperSize = CGPDFPageGetBoxRect(CGPDFDocumentGetPage (pdf, 1), kCGPDFMediaBox);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(context, 0, paperSize.size.height);
CGContextScaleCTM(context, 1.0, -1.0);
CGContextDrawPDFPage(context, page);
done = YES;
} while (!done);
UIGraphicsEndPDFContext();
}
如果從比iOS設備以外的源產生的源PDF它正在發生。