mirror of
https://github.com/zxing/zxing.git
synced 2024-11-10 04:54:04 -08:00
PDF417Writer shouldn't ignore ERROR_CORRECTION hint
This commit is contained in:
parent
8a87f159a3
commit
53875e4fd3
|
@ -27,7 +27,8 @@ public enum EncodeHintType {
|
||||||
* Specifies what degree of error correction to use, for example in QR Codes.
|
* Specifies what degree of error correction to use, for example in QR Codes.
|
||||||
* Type depends on the encoder. For example for QR codes it's type
|
* Type depends on the encoder. For example for QR codes it's type
|
||||||
* {@link com.google.zxing.qrcode.decoder.ErrorCorrectionLevel ErrorCorrectionLevel}.
|
* {@link com.google.zxing.qrcode.decoder.ErrorCorrectionLevel ErrorCorrectionLevel}.
|
||||||
* For Aztec it is of type {@link Integer}, representing the minimal percentage of error correction words.
|
* For Aztec it is of type {@link Integer}, representing the minimal percentage of error correction words.
|
||||||
|
* For PDF417 it is of type {@link Integer}, valid values being 0 to 8.
|
||||||
* Note: an Aztec symbol should have a minimum of 25% EC words.
|
* Note: an Aztec symbol should have a minimum of 25% EC words.
|
||||||
*/
|
*/
|
||||||
ERROR_CORRECTION,
|
ERROR_CORRECTION,
|
||||||
|
|
|
@ -39,6 +39,11 @@ public final class PDF417Writer implements Writer {
|
||||||
*/
|
*/
|
||||||
static final int WHITE_SPACE = 30;
|
static final int WHITE_SPACE = 30;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* default error correction level
|
||||||
|
*/
|
||||||
|
static final int DEFAULT_ERROR_CORRECTION_LEVEL = 2;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BitMatrix encode(String contents,
|
public BitMatrix encode(String contents,
|
||||||
BarcodeFormat format,
|
BarcodeFormat format,
|
||||||
|
@ -51,6 +56,7 @@ public final class PDF417Writer implements Writer {
|
||||||
|
|
||||||
PDF417 encoder = new PDF417();
|
PDF417 encoder = new PDF417();
|
||||||
int margin = WHITE_SPACE;
|
int margin = WHITE_SPACE;
|
||||||
|
int errorCorrectionLevel = DEFAULT_ERROR_CORRECTION_LEVEL;
|
||||||
|
|
||||||
if (hints != null) {
|
if (hints != null) {
|
||||||
if (hints.containsKey(EncodeHintType.PDF417_COMPACT)) {
|
if (hints.containsKey(EncodeHintType.PDF417_COMPACT)) {
|
||||||
|
@ -69,13 +75,16 @@ public final class PDF417Writer implements Writer {
|
||||||
if (hints.containsKey(EncodeHintType.MARGIN)) {
|
if (hints.containsKey(EncodeHintType.MARGIN)) {
|
||||||
margin = ((Number) hints.get(EncodeHintType.MARGIN)).intValue();
|
margin = ((Number) hints.get(EncodeHintType.MARGIN)).intValue();
|
||||||
}
|
}
|
||||||
|
if (hints.containsKey(EncodeHintType.ERROR_CORRECTION)) {
|
||||||
|
errorCorrectionLevel = ((Number) hints.get(EncodeHintType.ERROR_CORRECTION)).intValue();
|
||||||
|
}
|
||||||
if (hints.containsKey(EncodeHintType.CHARACTER_SET)) {
|
if (hints.containsKey(EncodeHintType.CHARACTER_SET)) {
|
||||||
String encoding = (String) hints.get(EncodeHintType.CHARACTER_SET);
|
String encoding = (String) hints.get(EncodeHintType.CHARACTER_SET);
|
||||||
encoder.setEncoding(Charset.forName(encoding));
|
encoder.setEncoding(Charset.forName(encoding));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return bitMatrixFromEncoder(encoder, contents, width, height, margin);
|
return bitMatrixFromEncoder(encoder, contents, errorCorrectionLevel, width, height, margin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -91,10 +100,10 @@ public final class PDF417Writer implements Writer {
|
||||||
*/
|
*/
|
||||||
private static BitMatrix bitMatrixFromEncoder(PDF417 encoder,
|
private static BitMatrix bitMatrixFromEncoder(PDF417 encoder,
|
||||||
String contents,
|
String contents,
|
||||||
|
int errorCorrectionLevel,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
int margin) throws WriterException {
|
int margin) throws WriterException {
|
||||||
int errorCorrectionLevel = 2;
|
|
||||||
encoder.generateBarcodeLogic(contents, errorCorrectionLevel);
|
encoder.generateBarcodeLogic(contents, errorCorrectionLevel);
|
||||||
|
|
||||||
int aspectRatio = 4;
|
int aspectRatio = 4;
|
||||||
|
|
Loading…
Reference in a new issue