- Posts: 1
- 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
How to use PDFView to addAnnotBitmap in 2.1.0
IP: 192.168.0.71
11 years 10 months ago #6097
by chpike
How to use PDFView to addAnnotBitmap in 2.1.0 was created by chpike
I added method in PDFPage Class.
Method is as Follows
And I added method in PDFView Class.
Method is as Follows
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.
Method is as Follows
Code:
- (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
Code:
- (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.
IP: 192.168.0.71
11 years 9 months ago #6339
by Rossi
Replied by Rossi on topic How to use PDFView to addAnnotBitmap in 2.1.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?
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?
IP: 192.168.0.127
11 years 9 months ago #6375
by emanuele
Replied by emanuele on topic How to use PDFView to addAnnotBitmap in 2.1.0
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 check this answer, I think is the same problem:
www.androidpdf.mobi/forum/ios-dev/1791-a...oesn-t-work-in-2-2-0
Time to create page: 0.406 seconds