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

Add an Image on PDF

More
IP: 192.168.0.71 9 years 4 months ago #12370 by Pja
Add an Image on PDF was created by Pja
Hi,

How do I add an Image on a page of document?
More
IP: 192.168.0.71 9 years 4 months ago #12371 by emanuele
Replied by emanuele on topic Add an Image on PDF
Hi,

you can take a look at this Knowledge Base article: www.radaeepdf.com/support/knowledge-base...component&kbartid=28
More
IP: 192.168.0.71 9 years 4 months ago #12382 by Pja
Replied by Pja on topic Add an Image on PDF
I tried using the given method, but this doesn't add the image on the document.
This adds the note image on the document.. But i need the image to be added directly on the document.
Is there any solution for this?
More
IP: 192.168.0.71 9 years 4 months ago #12383 by emanuele
Replied by emanuele on topic Add an Image on PDF
Hi,

here is a quick sample of how to add an image as resource and draw it on a page:
Code:
// Get page PDFPage *page = [m_doc page:0]; // Create page content PDFPageContent *content = [[PDFPageContent alloc] init]; // Get the image to add UIImage *img = [UIImage imageNamed:@"image"]; // Create a Doc Image instance PDFDocImage *image = [m_doc newImage:img.CGImage :YES]; // Add the image as page resource PDF_PAGE_IMAGE rimg = [page addResImage:image]; [content gsSave]; // Set the matrix (image position/size on page) PDFMatrix *matrix = [[PDFMatrix alloc] init:20 :20 :0 :0]; [content gsCatMatrix:matrix]; matrix = nil; // Draw the image on page content [content drawImage:rimg]; [content gsRestore]; // Add the content on the page [page addContent:content :false]; // Save the file [m_doc save];
More
IP: 192.168.0.71 9 years 4 months ago #12385 by Pja
Replied by Pja on topic Add an Image on PDF
Hi Emanuele,

I am using the given method to add the image
// Create the cache file
NSString *tp = NSTemporaryDirectory();
tp = [tp stringByAppendingPathComponent:@"cache.dat"];
[m_doc setCache:tp];

// Create the PDFPage instance of the current page
PDFPage *page = [m_doc page:m_cur_page];

// Create the CGImageRef of the image
CGImageRef ref = [[UIImage imageWithData:imageData] CGImage];

//NSString *path = @"path_to_image";
//PDFDocImage *i = [m_doc newImageJPEG:path];

// Get PDFDocImage instance from CGImageRef (keeping alpha channel)
PDFDocImage *i = [m_doc newImage:ref :YES];

// Define the image rect
PDF_RECT rect;

rect.left = 100;
rect.right = 157;
rect.top = 100;
rect.bottom = 157;

// Add the image

[page addAnnotBitmap:i :&rect];


// Re-render the current page
[m_view vRenderSync:m_cur_page];
[self refresh];
Here i am getting one problem, only with the rect used in the method the image is plotted at the bottom left corner of the page.
When i change any of the rect value the image is not seen.
Can you please explain me the significance of the Rect or what values should i provide to the rect?
I need to add the image at the point where i have long pressed on the pdf.
More
IP: 192.168.0.71 9 years 4 months ago #12402 by Pja
Replied by Pja on topic Add an Image on PDF
Any updates?
Time to create page: 0.438 seconds
Powered by Kunena Forum