Good day
I’m creating an for signing pdf digitally.
I want to sign a pdf , save it without making a duplicate. I want to replace the pdf with the signed one.
I tried using the NSFileManager to create a folder in the directory, copy the pdf to the new folder but failed.
NSArray *paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString* baseName = [[[[m_pdfViewCtrl GetDoc] GetFileName] lastPathComponent] stringByDeletingPathExtension];
NSString* signedPDFName = [baseName stringByAppendingString:@"-signed.pdf"];
NSString *newFolderStringPath = [documentsDirectory stringByAppendingPathComponent:@“Temp”];
if ([[NSFileManager defaultManager] createDirectoryAtPath:newFolderStringPath withIntermediateDirectories:YES attributes:nil error:nil]) {
NSData *contentData = [NSData dataWithContentsOfFile:[[m_pdfViewCtrl GetDoc] GetFileName]];
[contentData writeToFile:newFolderStringPath atomically:YES];
}
I also tried saving with the pdfTron way, but it says the file doesnt exist.
NSArray *paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString* baseName = [[[[m_pdfViewCtrl GetDoc] GetFileName] lastPathComponent] stringByDeletingPathExtension];
NSString* signedPDFName = [baseName stringByAppendingString:@"-signed.pdf"];
NSString *newFolderStringPath = [documentsDirectory stringByAppendingPathComponent:@“Temp”];
if ([[NSFileManager defaultManager] createDirectoryAtPath:newFolderStringPath withIntermediateDirectories:YES attributes:nil error:nil]) {
[doc SaveToFile:newFolderStringPath flags:e_ptincremental];
}
I dont know if I should have permission to copy and write to… Please help,
Thank you.