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

Converting document to NSDATA

More
10 years 5 months ago #9465 by Guest579
Hello,
I add the picture to my pdf document using :
Code:
- (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
More
10 years 5 months ago #9466 by emanuele
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.
More
10 years 5 months ago #9467 by Guest579
Thank you for your prompt reply.

But when I called
Code:
NSData*pdfData = [[NSFileManager defaultManager]contentsAtPath:fullPath];
into the add Image method I get the pdf document without the new added image?
Thank you
More
10 years 5 months ago #9468 by emanuele
is possible that your pdf is not in a writable directory?
More
10 years 5 months ago - 10 years 5 months ago #9469 by Guest579
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 :
Code:
- (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?
Last edit: 10 years 5 months ago by Guest579.
More
10 years 5 months ago #9470 by emanuele
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?
Time to create page: 0.452 seconds
Powered by Kunena Forum