Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add pdf data generating helper method (TODO: move to more logical place)

  • Loading branch information...
commit bf61785f555a26c20c9ee5ad323b0794f6c8e74d 1 parent 0ceb93c
Chris authored
Showing with 20 additions and 1 deletion.
  1. +2 −0  UIImage-NKDBarcode.h
  2. +18 −1 UIImage-NKDBarcode.m
View
2  UIImage-NKDBarcode.h
@@ -31,4 +31,6 @@ This category adds a single class method to NSImage that generates a resolution-
@result Initialized NSImage with PDF representation that represents the barcode pass in.
*/
+(UIImage *)imageFromBarcode:(NKDBarcode *)barcode;
++(NSData *)pdfFromBarcode:(NKDBarcode *)barcode;
++(UIImage *)imageFromBarcode:(NKDBarcode *)barcode inRect:(CGRect) rect;
@end
View
19 UIImage-NKDBarcode.m
@@ -16,7 +16,24 @@ +(UIImage *)imageFromBarcode:(NKDBarcode *)barcode
{
NKDBarcodeOffscreenView * view = [[NKDBarcodeOffscreenView alloc] initWithBarcode:barcode];
CGRect rect = [view bounds];
- UIImage * image = [view imageWithPNGInsideRect:rect];
+ UIImage * image = [view imageInsideRect:rect];
+ [view release];
+ return image;
+}
+
++(NSData *)pdfFromBarcode:(NKDBarcode *)barcode {
+ NKDBarcodeOffscreenView * view = [[NKDBarcodeOffscreenView alloc] initWithBarcode:barcode];
+ CGRect rect = [view bounds];
+ NSData * pdf = [view pdfInsideRect:rect];
+ [view release];
+ return pdf;
+}
+
++(UIImage *)imageFromBarcode:(NKDBarcode *)barcode inRect:(CGRect) rect
+{
+ NKDBarcodeOffscreenView * view = [[NKDBarcodeOffscreenView alloc] initWithBarcode:barcode];
+ [view setFrame:rect];
+ UIImage * image = [view imageInsideRect:rect];
[view release];
return image;
}
Please sign in to comment.
Something went wrong with that request. Please try again.