- Posts: 4
- Thank you received: 0
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
10 years 5 months ago #9465
by Guest579
Converting document to NSDATA was created by Guest579
Hello,
I add the picture to my pdf document using :
( 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
I add the picture to my pdf document using :
Code:
- (NSMutableData *)vAddImage:(NSData *)data withRect:(PDF_RECT)rect
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
10 years 5 months ago #9466
by emanuele
Replied by emanuele on topic Converting document to NSDATA
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 path is the same used to open the pdf file.
You can get the file data using the contentsAtPath method of NSFileManager class.
10 years 5 months ago #9467
by Guest579
Replied by Guest579 on topic Converting document to NSDATA
Thank you for your prompt reply.
But when I called
into the add Image method I get the pdf document without the new added image?
Thank you
But when I called
Code:
NSData*pdfData = [[NSFileManager defaultManager]contentsAtPath:fullPath];
Thank you
10 years 5 months ago #9468
by emanuele
Replied by emanuele on topic Converting document to NSDATA
is possible that your pdf is not in a writable directory?
10 years 5 months ago - 10 years 5 months ago #9469
by Guest579
Replied by Guest579 on topic Converting document to NSDATA
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 :
Please tell me;is there something missing in my code above for adding and saving the image into pdf?
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.
10 years 5 months ago #9470
by emanuele
Replied by emanuele on topic Converting document to NSDATA
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?
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