我一直在努力解决过去几个小时的问题。我以编程方式制作了一个 pdf 并将其保存在 ~/library/Application Support/iPhone Simulator/... 并且这些程序在模拟器中对我来说工作正常。我可以在 webView 中保存和检索 pdf。
但是当我在 iPhone4 设备上测试我的应用程序时,我在检索时看不到 pdf 文件。我是新手,所以我不知道手动检查是否在设备中创建了 pdf。
请给我帮助。
谢谢
我从这段代码中保存了pdf:
- (void)generatePdfButtonPressed{
pageSize = CGSizeMake(612, 792);
NSString *fileName = @"Demo.pdf";
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *pdfFileName = [documentsDirectory stringByAppendingPathComponent:fileName];
[self generatePdfWithFilePath:pdfFileName];
}
- (void) generatePdfWithFilePath: (NSString *)thefilePath
{
UIGraphicsBeginPDFContextToFile(thefilePath, CGRectZero, nil);
NSInteger currentPage = 0;
BOOL done = NO;
do
{
// Mark the beginning of a new page.
UIGraphicsBeginPDFPageWithInfo(CGRectMake(0, 0, pageSize.width, pageSize.height), nil);
// Draw a page number at the bottom of each page.
currentPage++;
//[self drawPageNumber:currentPage];
//Draw a border for each page.
// [self drawBorder];
//Draw text fo our header.
[self drawHeader];
//Draw a line below the header.
[self drawLine];
//Draw personel details
[self drawPersonelDetail];
//Draw Education
[self drawEducation];
//Draw work Experiences
[self drawWorkExperiences];
//Draw work Activities
[self drawActivities];
//Draw Skills
[self drawSkils];
//Draw some text for the page.
// [self drawText];
yCord=550;
// [self drawText];
//Draw an image
// [self drawImage];
done = YES;
}
while (!done);
// Close the PDF context and write the contents out.
UIGraphicsEndPDFContext();
}