### Generate Code 128 Barcode Image in Java Source: https://github.com/woo-j/okapibarcode/blob/master/README.md Use this snippet to generate a Code 128 barcode image in Java. It configures barcode properties and renders it to a PNG file using the Java 2D renderer. ```java Code128 barcode = new Code128(); barcode.setFontName("Monospaced"); barcode.setFontSize(16); barcode.setModuleWidth(2); barcode.setBarHeight(50); barcode.setHumanReadableLocation(HumanReadableLocation.BOTTOM); barcode.setContent("123456789"); int width = barcode.getWidth(); int height = barcode.getHeight(); BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_GRAY); Graphics2D g2d = image.createGraphics(); Java2DRenderer renderer = new Java2DRenderer(g2d, 1, Color.WHITE, Color.BLACK); renderer.render(barcode); ImageIO.write(image, "png", new File("code128.png")); ``` -------------------------------- ### Generate Barcode SVG for Android in Java Source: https://github.com/woo-j/okapibarcode/blob/master/README.md This snippet demonstrates how to generate an SVG representation of a Code 128 barcode using Java. The SVG content can then be used with Android libraries for rendering. ```java Code128 barcode = new Code128(); barcode.setFontName("Monospaced"); barcode.setFontSize(16); barcode.setModuleWidth(2); barcode.setBarHeight(50); barcode.setHumanReadableLocation(HumanReadableLocation.BOTTOM); barcode.setContent("123456789"); ByteArrayOutputStream stream = new ByteArrayOutputStream(); SvgRenderer renderer = new SvgRenderer(stream, 1, Color.WHITE, Color.BLACK, true); renderer.render(barcode); String content = new String(stream.toByteArray(), StandardCharsets.UTF_8); SVG svg = SVG.getFromString(content); svg.renderToCanvas(canvas); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.