0
我正在構建一個將生成PDF的應用程序。我可以很好地生成PDF,但它是一個單擊操作,用於構建和保存PDF。我想要做的是將其更改爲顯示PDF預覽,然後提供編輯選項的選項,或將其保存到「文檔」文件夾中。我怎麼能這樣做呢?這就是我保存的東西。在iOS中預覽PDF文檔之前保存
- (IBAction)generatePdfButtonPressed:(id)sender
{
pageSize = CGSizeMake(792, 612);
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);
BOOL done = NO;
do
{
UIGraphicsBeginPDFPageWithInfo(CGRectMake(0, 0, pageSize.width, pageSize.height), nil);
[self drawImage];
[self drawText];
[self drawText2];
[self drawText3];
[self drawText4];
done = YES;
}
while (!done);
// Close the PDF context and write the contents out.
UIGraphicsEndPDFContext();
}
我的問題是,我需要預覽PDF保存之前。你的建議會保存PDF,然後顯示它。我想要預覽選項,以便不首先保存文檔。 – user717452
有沒有什麼特別的原因可以挽救它?如果用戶取消或不再需要,您可以簡單地刪除文檔 – Stephen
而不是在Web視圖中加載文檔,只需將數據加載到uiwebview中,這將成爲您的預覽 –