- Posts: 37
- 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
adding image to pdf
9 years 2 months ago #11584
by Shades
adding image to pdf was created by Shades
Hi,
Need your help please to be able to add an image without alpha:
After that I am not able to see the image added even after invoking
Thank you for your help
Need your help please to be able to add an image without alpha:
Code:
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
Code:
[m_view vRenderSync:page];
9 years 2 months ago #11585
by stronglee
Replied by stronglee on topic adding image to pdf
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.
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.
9 years 2 months ago #11586
by stronglee
Replied by stronglee on topic adding image to pdf
If you want add image annot to PDF files,you can try AddAnnotBitmap method
9 years 2 months ago #11587
by Shades
Replied by Shades on topic adding image to pdf
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.
with AddAnnotBitmap,the image doesn't keep the transparent background .( the background is always white )That's why I am trying other methods.
9 years 2 months ago #11594
by emanuele
Replied by emanuele on topic adding image to pdf
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:
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:
Code:
// Get PDFDocImage instance from CGImageRef (keeping alpha channel)
PDFDocImage *i = [m_doc newImage:ref :YES];
// Add the image
[page addAnnotBitmap:i :&rect];
Time to create page: 0.418 seconds