Hi,
to add an image, you have to follow this steps:
- set Document cache properly in PDFOpen method:
NSString *cachesPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
cachesPath = [cachesPath stringByAppendingPathComponent:@"file.dat"];
bool ret1 = Document_setCache(m_doc, [cachesPath UTF8String]);
- add the image like others Annot, for example:
- (void)vAddImage
{
struct PDFV_POS pos;
[m_view vGetPos:&pos:x:y];
if(pos.pageno>=0)
{
PDFVPage *vpage = [m_view vGetPage:pos.pageno];
PDF_PAGE page = [vpage GetPage];
PDF_RECT rect;
rect.bottom = 300;
rect.left = 100;
rect.right = 300;
rect.top = 100;
if( page != NULL )
{
CGImageRef ref = [[UIImage imageNamed:@"italy.png"] CGImage];
PDF_MATRIX mat = [vpage CreateMatrix];
BOOL result = Page_addAnnotBitmap(page, mat, ref, 1, &rect);
Matrix_destroy(mat);
[m_view vRenderPage:pos.pageno];
Document_save(m_doc);
[self refresh];
}
}
}