adding image to pdf - 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

TOPIC: adding image to pdf

adding image to pdf 1 year 4 months ago #11584

  • Shades
  • Shades's Avatar Topic Author
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 37
  • Thank you received: 0
Hi,

Need your help please to be able to add an image without alpha:
CGRect drawRect = CGRectMake(100, 0, 300, 300);
  UIImage *img =[UIImage imageWithData:data];
    if(img){
             CGContextDrawImage(context, drawRect, img.CGImage);
      }

After that I am not able to see the image added even after invoking
[m_view vRenderSync:page];
Thank you for your help

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

adding image to pdf 1 year 4 months ago #11585

  • stronglee
  • stronglee's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 92
  • Karma: 1
  • Thank you received: 2
Hi,
did you check context is nil ?
and are you calling UIGraphicsGetCurrentContext() inside of the drawRect method? As far as I know, it can only be called within drawRect, otherwise it will just return nil.

I tried your method add into drawRect method ,it works.

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

adding image to pdf 1 year 4 months ago #11586

  • stronglee
  • stronglee's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 92
  • Karma: 1
  • Thank you received: 2
If you want add image annot to PDF files,you can try AddAnnotBitmap method :)

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

adding image to pdf 1 year 4 months ago #11587

  • Shades
  • Shades's Avatar Topic Author
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 37
  • Thank you received: 0
Thank you for your reply :)

with AddAnnotBitmap,the image doesn't keep the transparent background .( the background is always white )That's why I am trying other methods.

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

adding image to pdf 1 year 4 months ago #11594

  • emanuele
  • emanuele's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 489
  • Karma: 15
  • Thank you received: 53
Hi,

you can download the new beta version here , with the new PDFDoc method: [PDFDoc newImage] that uses a CGImageRef to create a PDFDocImage object.
Here is an example:
// Get PDFDocImage instance from CGImageRef (keeping alpha channel)
PDFDocImage *i = [m_doc newImage:ref :YES];
    
// Add the image
[page addAnnotBitmap:i :&rect];
The following user(s) said Thank You: Shades

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

adding image to pdf 1 year 4 months ago #11597

  • Shades
  • Shades's Avatar Topic Author
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 37
  • Thank you received: 0
Thank you very much for your help !! :)

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

  • Page:
  • 1
Powered by Kunena Forum