RadaeePDF.com :: Topic: adding image to pdf (1/1)
Welcome, Guest
Username: Password: Remember me

Signin/Signup with:

Questions about iOS development and PDF

TOPIC: adding image to pdf

adding image to pdf 6 months 1 week ago #11584

  • Shades
  • Shades's Avatar
  • OFFLINE
  • Junior Boarder
  • Posts: 35
  • Karma: 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
The administrator has disabled public write access.

adding image to pdf 6 months 1 week ago #11585

  • stronglee
  • stronglee's Avatar
  • OFFLINE
  • Moderator
  • Posts: 82
  • Thank you received: 2
  • Karma: 1
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.
The administrator has disabled public write access.

adding image to pdf 6 months 1 week ago #11586

  • stronglee
  • stronglee's Avatar
  • OFFLINE
  • Moderator
  • Posts: 82
  • Thank you received: 2
  • Karma: 1
If you want add image annot to PDF files,you can try AddAnnotBitmap method :)
The administrator has disabled public write access.

adding image to pdf 6 months 1 week ago #11587

  • Shades
  • Shades's Avatar
  • OFFLINE
  • Junior Boarder
  • Posts: 35
  • Karma: 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.
The administrator has disabled public write access.

adding image to pdf 6 months 6 days ago #11594

  • emanuele
  • emanuele's Avatar
  • OFFLINE
  • Moderator
  • Posts: 388
  • Thank you received: 40
  • Karma: 11
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 administrator has disabled public write access.
The following user(s) said Thank You: Shades

adding image to pdf 6 months 5 days ago #11597

  • Shades
  • Shades's Avatar
  • OFFLINE
  • Junior Boarder
  • Posts: 35
  • Karma: 0
Thank you very much for your help !! :)
The administrator has disabled public write access.
Powered by Kunena Forum