I want to show pdf from certain page to certain page not whole pdf. - RadaeePDF.com - Results from #6
Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
Questions about iOS development and PDF

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

I want to show pdf from certain page to certain page not whole pdf. 2 months 3 weeks ago #14389

  • apdeveloper
  • apdeveloper's Avatar Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 50
  • Thank you received: 0
Dear Team,
Thank you for your reply.

The above code which you have shared is giving an error for this lines.
[doc_src open:@"source path to extists pdf file"]; //No visible @interface for 'PDFDoc' declares the selector 'open:'
[doc_dst open:@"dest path to creating pdf file"];//No visible @interface for 'PDFDoc' declares the selector 'open:'
PDFImportCtx *ctx = [doc_src newImportCtx]; //No visible @interface for 'PDFDoc' declares the selector 'newImportCtx'

Please Log in or Create an account to join the conversation.

I want to show pdf from certain page to certain page not whole pdf. 2 months 3 weeks ago #14390

  • emanuele
  • emanuele's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 566
  • Karma: 21
  • Thank you received: 65
Hi,
simply missing pwd and doc_src params, here is the code:
PDFDoc *doc_src;
    PDFDoc *doc_dst;
    doc_src = [[PDFDoc alloc] init];
    doc_dst = [[PDFDoc alloc] init];
    [doc_src open:@"path to file" :@"file pwd"];
    [doc_dst open:@"path to file" :@"file pwd"];
    PDFImportCtx *ctx = [doc_dst newImportCtx:doc_src];
    int pgno = 5;
    int pgend = 10;
    int pgdst = 0;
    while(pgno < pgend)
    {
        [ctx import :pgno :pgdst];
        pgno++;
        pgdst++;
    }
    [doc_dst save];
    ctx = nil;
    doc_src = nil;
    doc_dst = nil;

Please Log in or Create an account to join the conversation.

I want to show pdf from certain page to certain page not whole pdf. 2 months 3 weeks ago #14394

  • apdeveloper
  • apdeveloper's Avatar Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 50
  • Thank you received: 0
Hi Team,
I have called the function which you have send from my swift project to objective c
below is the code.
//Swift Project
plugin.createPDF(filepath, pdfDestination: destFilePathforAgenda, pdfPassword: Password, startPageNo: 1, endPageNo: 1)

let reader = plugin.show(destFilePathforAgenda, atPage: 0, withPassword: Password, 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)
}
//In Objective C
-(void)createPDF:(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 open:pdfDestination :pdfPassword];
NSLog(@"Source----%@",PDFsource);
NSLog(@"Destination----%@",pdfDestination);
NSLog(@"Password----%@",pdfPassword);
PDFImportCtx *ctx = [doc_dst newImportCtx:doc_src];
int pgno = startPageNo;
int pgend = endPageNo;
int pgdst = 0;
while(pgno < pgend)
{
[ctx import :pgno :pgdst];
pgno++;
pgdst++;
}
[doc_dst save];
ctx = nil;
doc_src = nil;
doc_dst = nil;
NSLog(@"created PDF");
}

No file is been created when i have called the createPDF function reader is nil when opening the PDF file with new PDF destination url which we have created.

Please Log in or Create an account to join the conversation.

I want to show pdf from certain page to certain page not whole pdf. 2 months 3 weeks ago #14395

  • radaee
  • radaee's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 883
  • Karma: 43
  • Thank you received: 15
sorry, some wrong on previous codes, you shall call [PDFDoc create] to create PDF file.
so codes like:
PDFDoc *doc_src;
PDFDoc *doc_dst;
doc_src = [[PDFDoc alloc] init];
doc_dst = [[PDFDoc alloc] init];
[doc_src open:@"source path to extists pdf file", @"password"];
[doc_dst create:@"dest path to creating pdf file"];
PDFImportCtx *ctx = [doc_src newImportCtx];
int pgno = page_range_start;
int pgend = page_range_end;
int pgdst = 0;
wile(pgno < pgend)
{
  [ctx import :pgno :pgdst];
  pgno++;
  pgdst++;
}
[doc_dst save];
ctx = nil;
doc_src = nil;
doc_dst = nil;


[doc_src open:@"source path to extists pdf file", @"password"];
[doc_dst create:@"dest path to creating pdf file"];


these 2 invoking is most important.
and both path shall be in sandbox of app.

Please Log in or Create an account to join the conversation.

Last edit: by radaee.

I want to show pdf from certain page to certain page not whole pdf. 2 months 2 weeks ago #14400

  • apdeveloper
  • apdeveloper's Avatar Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 50
  • Thank you received: 0
Dear Team,

Pdf is not getting created as both the path are of sandbox of app.
//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)

//reader is nil always and app is getting crash.
for creating pdf i have used the last code which you have send for creating pdf.

Please Log in or Create an account to join the conversation.

I want to show pdf from certain page to certain page not whole pdf. 2 months 2 weeks ago #14404

  • federico
  • federico's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 76
  • Thank you received: 7
Dear apdeveloper,
Here's create PDF's working method:
PDFDoc *doc_src;
    PDFDoc *doc_dst;
    doc_src = [[PDFDoc alloc] init];
    doc_dst = [[PDFDoc alloc] init];
    [doc_src open:@"your source path" :@"password"];
    [doc_dst create:@"your destination path"];
    PDFImportCtx *ctx = [doc_dst newImportCtx:doc_src];
    int pgno = 5;
    int pgend = 10;
    int pgdst = 0;
    while(pgno < pgend)
    {
        [ctx import :pgno :pgdst];
        pgno++;
        pgdst++;
    }
    [doc_dst save];
    ctx = nil;
    doc_src = nil;
    doc_dst = nil;

Please Log in or Create an account to join the conversation.

Powered by Kunena Forum