Dear Team,
New Pdf file has been created and even i am able to open the original pdf file.
//Below is the code of Swift Project
//RadaeePDFPlugin.h file method created.
-(void)createAgendaPDf:(NSString *)PDFsource pdfDestination:(NSString *)pdfDestination pdfPassword:(NSString *)pdfPassword startPageNo:(int)startPageNo endPageNo:(int)endPageNo;
//Below is function to call the method.
var destFilePathforPdf = "\(filepath)\("_")\(outlineData.replacingOccurrences(of: " ", with: ""))"
destFilePathforPdf = destFilePathforPdf.replacingOccurrences(of: ".", with: "")
let fileManager = FileManager.default
if(!fileManager.fileExists(atPath: destFilePathforPdf)){
print("file Not Exits
")
plugin.createAgendaPDf(filepath, pdfDestination: destFilePathforPdf, pdfPassword: Password, startPageNo: 1, endPageNo: 2)
let reader = plugin.show(destFilePathforPdf, atPage: 0, withPassword: "", readOnly: false, autoSave: true)
if (reader == nil) {
alert(title: "No Such File", message: "")
}else{
let vc: UIViewController = reader1 as! UIViewController
self.navigationController?.navigationBar.isTranslucent = false;
self.navigationController?.pushViewController(vc, animated: true)
}
}else{
print("file Exits
")
let reader = plugin.show(destFilePathforPdf, atPage: 0, withPassword: "", readOnly: false, autoSave: true)
if (reader == nil) {
alert(title: "No Such File", message: "")
}else{
let vc: UIViewController = reader1 as! UIViewController
self.navigationController?.navigationBar.isTranslucent = false;
self.navigationController?.pushViewController(vc, animated: true)
}
}
//Below is code for Objective C project.
//RadaeePDFPlugin.h file method created.
-(void)createAgendaPDf:(NSString *)PDFsource pdfDestination:(NSString *)pdfDestination pdfPassword:(NSString *)pdfPassword startPageNo:(int)startPageNo endPageNo:(int)endPageNo;
//In RadaeePDFPlugin.m file
-(void)createAgendaPDf:(NSString *)PDFsource pdfDestination:(NSString *)pdfDestination pdfPassword:(NSString *)pdfPassword startPageNo:(int)startPageNo endPageNo:(int)endPageNo{
PDFDoc *doc_src;
PDFDoc *doc_dst;
doc_src = [[PDFDoc alloc] init];
doc_dst = [[PDFDoc alloc] init];
[doc_src open:PDFsource :pdfPassword];
[doc_dst create:pdfDestination];
PDFImportCtx *ctx = [doc_dst newImportCtx:doc_src];
int pgno = startPageNo;
int pgend = 2;
int pgdst = endPageNo;
while(pgno < pgend)
{
[ctx import :pgno :pgdst];
pgno++;
pgdst++;
}
[doc_dst save];
ctx = nil;
doc_src = nil;
doc_dst = nil;
NSLog(@"created Agenda");
}