newImageJPEG always nil - RadaeePDF.com
Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
13 Jul 2017
Microsoft has ended support for Windows Phone 8.1
Read More...
Questions about iOS development and PDF
  • Page:
  • 1
  • 2

TOPIC: newImageJPEG always nil

newImageJPEG always nil 4 years 3 months ago #6931

  • sparklellama
  • sparklellama's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 34
  • Thank you received: 0
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):

    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:

	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

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

newImageJPEG always nil 4 years 3 months ago #6932

  • radaee
  • radaee's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 846
  • Karma: 43
  • Thank you received: 12
this method need 2 condition:
1. a premium license is needed.
2. [PDFDoc setCache] invoked.

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

newImageJPEG always nil 4 years 3 months ago #6933

  • sparklellama
  • sparklellama's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 34
  • Thank you received: 0
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.

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

newImageJPEG always nil 4 years 3 months ago #6937

  • radaee
  • radaee's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 846
  • Karma: 43
  • Thank you received: 12
setCache calls like this code:
m_doc = [[PDFDoc alloc] init];
NSString* tp = NSTemporaryDirectory();
tp = [tp stringByAppendingString:@"/cache.dat"];
err = [m_doc open:path :pwd];
[m_doc setCache:tp];

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

Last edit: by .

newImageJPEG always nil 4 years 3 months ago #6940

  • sparklellama
  • sparklellama's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 34
  • Thank you received: 0
Thanks for your help so far. I am very sorry but the suggested code does not appear to work. I now have the following:
        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):
        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.

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

newImageJPEG always nil 4 years 3 months ago #6943

  • radaee
  • radaee's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 846
  • Karma: 43
  • Thank you received: 12
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.
The following user(s) said Thank You: soumyaranjan.behera@ggktech.com

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

  • Page:
  • 1
  • 2
Powered by Kunena Forum