Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
Questions about iOS development and PDF
  • Page:
  • 1
  • 2

TOPIC:

Converting document to NSDATA 8 years 8 months ago #9465

  • Guest579
  • Guest579's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 4
  • Thank you received: 0
Hello,
I add the picture to my pdf document using :
- (NSMutableData *)vAddImage:(NSData *)data withRect:(PDF_RECT)rect
( According to www.radaeepdf.com/forum/ios-dev/2580-how-to-add-a-picture)

Is there a way to get the full path of the document after saving the picture ? Or converting it to binary data(NSDATA )?

Thank you

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

Converting document to NSDATA 8 years 8 months ago #9466

  • emanuele
  • emanuele's Avatar
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 580
  • Thank you received: 67
Hi,

the path is the same used to open the pdf file.
You can get the file data using the contentsAtPath method of NSFileManager class.
The following user(s) said Thank You: Guest579

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

Converting document to NSDATA 8 years 8 months ago #9467

  • Guest579
  • Guest579's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 4
  • Thank you received: 0
Thank you for your prompt reply.

But when I called
NSData*pdfData = [[NSFileManager defaultManager]contentsAtPath:fullPath];
into the add Image method I get the pdf document without the new added image?
Thank you

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

Converting document to NSDATA 8 years 8 months ago #9468

  • emanuele
  • emanuele's Avatar
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 580
  • Thank you received: 67
is possible that your pdf is not in a writable directory?

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

Converting document to NSDATA 8 years 8 months ago #9469

  • Guest579
  • Guest579's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 4
  • Thank you received: 0
Well the pdf is in a writable directory.But I am not sure if the image is saved properly or not.Here is my code.
That's how I call the add method :
- (NSData *)vAddImage:(NSData *)data withRect:(PDF_RECT)rect
{
   NSString *tp = NSTemporaryDirectory();
    tp = [tp stringByAppendingPathComponent:@"cache.dat"];
    [m_doc setCache:tp];
    PDFPage *page = [m_doc page:m_cur_page];
    CGImageRef ref = [UIImage imageWithData:data].CGImage;
    [page addAnnotBitmap:ref :NO :&rect];
    
    [m_view vRenderSync:m_cur_page];
    [self refresh];
    [m_doc save];
    NSData *pdfData = [[NSFileManager defaultManager]contentsAtPath: fullPath];
    return pdfData;

}

Please tell me;is there something missing in my code above for adding and saving the image into pdf?

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

Last edit: by Guest579.

Converting document to NSDATA 8 years 8 months ago #9470

  • emanuele
  • emanuele's Avatar
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 580
  • Thank you received: 67
You can try to check the save result with something like bool res = [m_doc save];
if the result is YES, the pdf is saved correctly.
Are you able to see the pdf page with the image after vAddImage method has been called?
The following user(s) said Thank You: Guest579

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

  • Page:
  • 1
  • 2
Powered by Kunena Forum