Microsoft Windows Phone 8.1 support ends (13 Jul 2017)

Microsoft has ended support for Windows Phone 8.1

Questions about iOS development and PDF

I want to show pdf from certain page to certain page not whole pdf.

More
IP: 114.143.90.14 6 years 9 months ago #14405 by apdeveloper
Dear Team,
You have shared the same code which you have already shared with me in the above answer.
My question was to you that reader is nil and app gets crash when i am opening the pdf.

//Below is the code which i am calling for creating pdf and opening pdf from my swift project.

plugin.createAgendaPDf(filepath, pdfDestination: destFilePathforPDF, pdfPassword: Password, startPageNo: 1, endPageNo: 2)
let reader = plugin.show(destFilePathforPDF, atPage: 0, withPassword: "", readOnly: false, autoSave: true)
More
IP: 212.97.62.176 6 years 9 months ago #14406 by emanuele
it is not the same code, please focus on these lines:
Code:
[doc_src open:@"your source path" :@"password"]; [doc_dst create:@"your destination path"]; PDFImportCtx *ctx = [doc_dst newImportCtx:doc_src];
Are you able to check if the new pdf file has been created correctly before calling show method?
We tried the shared method (with valid doc path) in Swift demo and we are able to create the new file correctly.
Could you please share also the implementation of createAgendaPDf method?
Are you able to open the original file with show method? (without calling createAgendaPDf)
More
IP: 114.143.90.14 6 years 9 months ago #14407 by apdeveloper
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");
}
More
IP: 212.97.62.176 6 years 9 months ago #14408 by emanuele
I think that this part is wrong:
Code:
int pgno = startPageNo; int pgend = 2; int pgdst = endPageNo;

pgno it's the start page (it's ok), pgend it's the end page and you have to assign your endPageNo.
pgdest is the destination page of the new file, so, in this case, it must be initialized with 0.
Something like:
Code:
int pgno = startPageNo; int pgend = endPageNo; int pgdst = 0;

Please check if it fixes your code.
More
IP: 114.143.90.14 6 years 9 months ago #14409 by apdeveloper
Dear Team,
This does not resolve my issue can you please check.
More
IP: 212.97.62.176 6 years 9 months ago - 6 years 9 months ago #14410 by emanuele
We are still not able to reproduce your issue, we are able to create a new pdf file with the shared method and open it.
Could you please share your test pdf file?

Here is the Swift code used to check the feature:
Code:
let documentsPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] let path: String = documentsPath + "/test.pdf" let plugin: RadaeePDFPlugin = self.pluginInit() plugin.setDelegate(self); plugin.createAgendaPDf(path, pdfDestination: documentsPath + "/new.pdf", pdfPassword: "", startPageNo: 1, endPageNo: 2); let reader = plugin.show(documentsPath + "/new.pdf", withPassword: "")

Another quick info: where are located your source and destination files?
Last edit: 6 years 9 months ago by emanuele.
Time to create page: 0.371 seconds
Powered by Kunena Forum