Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
Questions about iOS development and PDF
  • Page:
  • 1
  • 2

TOPIC:

How add UIimage 10 years 5 months ago #4370

  • emanuele
  • emanuele's Avatar
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 580
  • Thank you received: 67
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];
    }
    }
    }

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

Last edit: by CBA.
  • Page:
  • 1
  • 2
Powered by Kunena Forum