- Posts: 34
- 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
newImageJPEG always nil
- sparklellama
- Topic Author
- Offline
- Junior Member
-
Less
More
IP: 192.168.0.71
11 years 7 months ago #6931
by sparklellama
newImageJPEG always nil was created by sparklellama
I cannot seem to add an image to my PDF content using the iOS version of the library. My code follows. I have tried to open the document using a cache (as other topics on this forum suggest). I am noir sure if I have done it right or not.
Any help appreciated! Rather urgent. Thanks.
Here is how I open the document (seems to work OK):
Here is how I am adding the image:
Any help appreciated! Rather urgent. Thanks.
Here is how I open the document (seems to work OK):
Code:
m_doc = [[PDFDoc alloc] init];
NSString* tp = NSTemporaryDirectory();
//tp = [tp stringByAppendingPathComponent:@"cache"];
err = [m_doc open:path :pwd];
[m_doc setCache:tp];
Here is how I am adding the image:
Code:
UIImage* temp = [UIImage imageNamed:@"Signature"];
NSString* path = NSTemporaryDirectory();
path = [path stringByAppendingPathComponent:@"Signature.jpg"];
[UIImageJPEGRepresentation(temp, 0) writeToFile:path atomically:YES];
PDFDocImage* i = [m_doc newImageJPEG:path]; // always returns nil
IP: 192.168.0.71
11 years 7 months ago #6932
by radaee
Replied by radaee on topic newImageJPEG always nil
this method need 2 condition:
1. a premium license is needed.
2. [PDFDoc setCache] invoked.
1. a premium license is needed.
2. [PDFDoc setCache] invoked.
- sparklellama
- Topic Author
- Offline
- Junior Member
-
Less
More
- Posts: 34
- Thank you received: 0
IP: 192.168.0.71
11 years 7 months ago #6933
by sparklellama
Replied by sparklellama on topic newImageJPEG always nil
Thanks for the quick reply. I am using the demo license at the moment using "ActivatePremium" (I see the "RadaeePDF" watermark - until we organise payment shortly). This would work, right? Also, as you can see in the code above, I am using the setCache invocation.
IP: 192.168.0.71
11 years 7 months ago - 11 years 7 months ago #6937
by radaee
Replied by radaee on topic newImageJPEG always nil
setCache calls like this code:
Code:
m_doc = [[PDFDoc alloc] init];
NSString* tp = NSTemporaryDirectory();
tp = [tp stringByAppendingString:@"/cache.dat"];
err = [m_doc open:path :pwd];
[m_doc setCache:tp];
Last edit: 11 years 7 months ago by .
- sparklellama
- Topic Author
- Offline
- Junior Member
-
Less
More
- Posts: 34
- Thank you received: 0
IP: 192.168.0.71
11 years 7 months ago #6940
by sparklellama
Replied by sparklellama on topic newImageJPEG always nil
Thanks for your help so far. I am very sorry but the suggested code does not appear to work. I now have the following:
I have also tried (no leading slash):
But it does not appear to have made any difference. Thanks you very much if you can think of anything else that may be the problem.
Code:
m_doc = [[PDFDoc alloc] init];
NSString* tp = NSTemporaryDirectory();
tp = [tp stringByAppendingPathComponent:@"/cache.dat"];
err = [m_doc open:path :pwd];
[m_doc setCache:tp];
I have also tried (no leading slash):
Code:
m_doc = [[PDFDoc alloc] init];
NSString* tp = NSTemporaryDirectory();
tp = [tp stringByAppendingPathComponent:@"cache.dat"];
err = [m_doc open:path :pwd];
[m_doc setCache:tp];
But it does not appear to have made any difference. Thanks you very much if you can think of anything else that may be the problem.
IP: 192.168.0.71
11 years 7 months ago #6943
by radaee
Replied by radaee on topic newImageJPEG always nil
other problems maybe:
1. [Document canSave] return false, mostly because of write access right for PDF file.
2. jpeg file not compitable or damaged, currently support RGB/Gray/CMYK colorspace.
1. [Document canSave] return false, mostly because of write access right for PDF file.
2. jpeg file not compitable or damaged, currently support RGB/Gray/CMYK colorspace.
Time to create page: 0.408 seconds