4

I am using the following code for generate a barcode and display the barcode in a current view

OBLinear *pLinear = [OBLinear new];
    [pLinear setNBarcodeType: OB_CODE128A];
    [pLinear setPDataMsg: [[NSString alloc] initWithString: (@"SUKUMAR")]];
    //[pLinear setPSupData: [[NSString alloc] initWithString: (@"14562")]];
    [pLinear setFX: USER_DEF_BAR_WIDTH];
    [pLinear setFY: USER_DEF_BAR_HEIGHT];

    [pLinear setFLeftMargin: (USER_DEF_LEFT_MARGIN)];
    [pLinear setFRightMargin: (USER_DEF_RIGHT_MARGIN)];
    [pLinear setFTopMargin: (USER_DEF_TOP_MARGIN)];
    [pLinear setFBottomMargin: (USER_DEF_BOTTOM_MARGIN)];

    [pLinear setNRotate: (OB_Rotate0)];

    UIFont *pTextFont = [UIFont fontWithName: @"Arial" size: 8.0f];
    [pLinear setPTextFont: pTextFont];

 [pLinear drawWithView:view];

This is working fine, however I need to generated the barcode without showing it in the view.

How can I generate barcode images with out displaying it in the view. If any one knows how to do this, please help me.

Thanks in advance...

nycynik
  • 7,371
  • 8
  • 62
  • 87
sukumar
  • 65
  • 1
  • 5
  • 2
    Welcome to stack overflow. I understand that English is not your first language. However, I cannot understand your question. Please edit your post and try to write your question better. Try to use capitalization and punctuation (like starting each sentence with a capital letter and ending each sentence with a period). Try to explain what you need more clearly. If you cannot write it better, try to find someone who speaks your native language and can help you write it better in English. We cannot help you if we do not understand your question. – rob mayoff Dec 01 '12 at 06:08
  • ya correct English is not my primary language.. sorry for my bad English.. please try to understand and help me to come out of this problem – sukumar Dec 01 '12 at 06:27
  • @sukumar Did one of these answers solve your problem? If so please mark it as such. Thanks! – Miles Alden Dec 14 '12 at 18:17
  • possible duplicate of [Barcode Generation inside of IOS](http://stackoverflow.com/questions/5759073/barcode-generation-inside-of-ios) – Abizern Jan 16 '14 at 15:16

2 Answers2

3

I guess this is the interface of the class you're using: OBLinear.h

If that's so, it looks like you can generate a UIImage just by doing this:

UIImage *image;
[plLinear drawWithImage:&image];

Then you can do whatever you want with image. For example, you can convert it to a PNG using UIImagePNGRepresentation and upload the PNG data to your server, or save it to a file.

rob mayoff
  • 375,296
  • 67
  • 796
  • 848
  • Thank you so much for your reply.ya correct this is the interface of the class you're using: OBLiner.h only. I used the above code then where the generated image is stored.how can i get the generated image in my application resourse folder. If you know reply to this and help me please. – sukumar Dec 01 '12 at 06:40
  • The code I showed creates the image in memory as a `UIImage` object. You can save it to your app's Documents folder. If you don't know how to do that, you can find lots of help using Google. You cannot write to your app's resource folder on the device. – rob mayoff Dec 01 '12 at 06:50
1

You probably are looking for something like this SO question:

Capture UIView as UIImage

Community
  • 1
  • 1
Miles Alden
  • 1,542
  • 1
  • 11
  • 21