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

TOPIC:

How to use PDFView to addAnnotBitmap in 2.1.0 9 years 11 months ago #6097

  • chpike
  • chpike's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 1
  • Thank you received: 0
I added method in PDFPage Class.
Method is as Follows
- (BOOL)addAnnotBitmap:(PDF_MATRIX)matrix :(CGImageRef)bitmap :(BOOL)has_alpha :(const PDF_RECT *)rect  {
    return Page_addAnnotBitmap(m_page, matrix, bitmap, has_alpha, rect);
}

And I added method in PDFView Class.
Method is as Follows
- (void)addImageWithImage:(UIImage *)image1
{
    
    UIImage *image = [UIImage imageNamed:@"test.png"];
    
    CGImageRef cgimage = image.CGImage;
    
    size_t width  = CGImageGetWidth(cgimage);
    size_t height = CGImageGetHeight(cgimage);
    
    size_t bpr = CGImageGetBytesPerRow(cgimage);
    size_t bpp = CGImageGetBitsPerPixel(cgimage);
    size_t bpc = CGImageGetBitsPerComponent(cgimage);
    size_t bytes_per_pixel = bpp / bpc;
    
    CGBitmapInfo info = CGImageGetBitmapInfo(cgimage);
    
    NSLog(
          @"\n"
          "===== %@ =====\n"
          "CGImageGetHeight: %d\n"
          "CGImageGetWidth:  %d\n"
          "CGImageGetColorSpace: %@\n"
          "CGImageGetBitsPerPixel:     %d\n"
          "CGImageGetBitsPerComponent: %d\n"
          "CGImageGetBytesPerRow:      %d\n"
          "CGImageGetBitmapInfo: 0x%.8X\n"
          "  kCGBitmapAlphaInfoMask     = %s\n"
          "  kCGBitmapFloatComponents   = %s\n"
          "  kCGBitmapByteOrderMask     = 0x%.8X\n"
          "  kCGBitmapByteOrderDefault  = %s\n"
          "  kCGBitmapByteOrder16Little = %s\n"
          "  kCGBitmapByteOrder32Little = %s\n"
          "  kCGBitmapByteOrder16Big    = %s\n"
          "  kCGBitmapByteOrder32Big    = %s\n",
          @"stamp",
          (int)width,
          (int)height,
          CGImageGetColorSpace(cgimage),
          (int)bpp,
          (int)bpc,
          (int)bpr,
          (unsigned)info,
          (info & kCGBitmapAlphaInfoMask)     ? "YES" : "NO",
          (info & kCGBitmapFloatComponents)   ? "YES" : "NO",
          (info & kCGBitmapByteOrderMask),
          ((info & kCGBitmapByteOrderMask) == kCGBitmapByteOrderDefault)  ? "YES" : "NO",
          ((info & kCGBitmapByteOrderMask) == kCGBitmapByteOrder16Little) ? "YES" : "NO",
          ((info & kCGBitmapByteOrderMask) == kCGBitmapByteOrder32Little) ? "YES" : "NO",
          ((info & kCGBitmapByteOrderMask) == kCGBitmapByteOrder16Big)    ? "YES" : "NO",
          ((info & kCGBitmapByteOrderMask) == kCGBitmapByteOrder32Big)    ? "YES" : "NO"
          );
    
    PDFVPage *vpage = [m_view vGetPage:0];
    PDFPage   *page = [vpage GetPage];
    PDFMatrix *mat = [vpage CreateMatrix];
    
    PDF_RECT rectInPDF;
    rectInPDF.left   = 0;
    rectInPDF.top    = 0;
    rectInPDF.right  = rectInPDF.left + image.size.width;
    rectInPDF.bottom = rectInPDF.top  + image.size.height;
    
    [mat invert];
    [mat transformRect:&rectInPDF];
    
    if ([page addAnnotBitmap:mat.handle :image.CGImage :YES :&rectInPDF]) {
        NSLog(@"success");
    } else {
        NSLog(@"fail");
    }
    NSLog(@"annotCount := %d", [page annotCount]);
    
    [m_view vRenderPage:0];
    
    m_modified = true;
    [m_doc save];
    m_status = sta_none;
    m_ink = NULL;
    [self refresh];


}

After adding the code, I received the value that annotation has added, successfully.

But,

I can't see annotation in PDF document also annotation hasn't added.
(And there wasn't no change at value of annotation count)


How bitmap annotation add in PDF document.

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

How to use PDFView to addAnnotBitmap in 2.1.0 9 years 10 months ago #6339

  • Rossi
  • Rossi's Avatar
  • Offline
  • Senior Member
  • Senior Member
  • Posts: 49
  • Thank you received: 0
Hi, I have the same issue. The addAnnotBitmap method return 1 but a see anything. If i look for the last annotation type it return 15 (ink annotation) that is the last annotation that i inserted.
I also tried to use Page_addBitmap but xcode return the following error:
Undefined symbols for architecture i386:
"_Page_addBitmap", referenced from:
so seem there isn't this method.
How can I add image to my pdf?

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

How to use PDFView to addAnnotBitmap in 2.1.0 9 years 10 months ago #6375

  • emanuele
  • emanuele's Avatar
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 580
  • Thank you received: 67
Hi,

please check this answer, I think is the same problem:

www.androidpdf.mobi/forum/ios-dev/1791-a...oesn-t-work-in-2-2-0

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

  • Page:
  • 1
Powered by Kunena Forum