com.google.zxing.pdf417.encoder.Dimensions Java Examples

The following examples show how to use com.google.zxing.pdf417.encoder.Dimensions. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PDF417Writer.java    From ZXing-Orient with Apache License 2.0 5 votes vote down vote up
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        Map<EncodeHintType,?> hints) throws WriterException {
  if (format != BarcodeFormat.PDF_417) {
    throw new IllegalArgumentException("Can only encode PDF_417, but got " + format);
  }

  PDF417 encoder = new PDF417();
  int margin = WHITE_SPACE;

  if (hints != null) {
    if (hints.containsKey(EncodeHintType.PDF417_COMPACT)) {
      encoder.setCompact((Boolean) hints.get(EncodeHintType.PDF417_COMPACT));
    }
    if (hints.containsKey(EncodeHintType.PDF417_COMPACTION)) {
      encoder.setCompaction((Compaction) hints.get(EncodeHintType.PDF417_COMPACTION));
    }
    if (hints.containsKey(EncodeHintType.PDF417_DIMENSIONS)) {
      Dimensions dimensions = (Dimensions) hints.get(EncodeHintType.PDF417_DIMENSIONS);
      encoder.setDimensions(dimensions.getMaxCols(),
                            dimensions.getMinCols(),
                            dimensions.getMaxRows(),
                            dimensions.getMinRows());
    }
    if (hints.containsKey(EncodeHintType.MARGIN)) {
      margin = ((Number) hints.get(EncodeHintType.MARGIN)).intValue();
    }
    if (hints.containsKey(EncodeHintType.CHARACTER_SET)) {
      String encoding = (String) hints.get(EncodeHintType.CHARACTER_SET);
      encoder.setEncoding(Charset.forName(encoding));
    }
  }

  return bitMatrixFromEncoder(encoder, contents, width, height, margin);
}
 
Example #2
Source File: PDF417Writer.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 4 votes vote down vote up
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        Map<EncodeHintType,?> hints) throws WriterException {
  if (format != BarcodeFormat.PDF_417) {
    throw new IllegalArgumentException("Can only encode PDF_417, but got " + format);
  }

  PDF417 encoder = new PDF417();
  int margin = WHITE_SPACE;
  int errorCorrectionLevel = DEFAULT_ERROR_CORRECTION_LEVEL;

  if (hints != null) {
    if (hints.containsKey(EncodeHintType.PDF417_COMPACT)) {
      encoder.setCompact(Boolean.valueOf(hints.get(EncodeHintType.PDF417_COMPACT).toString()));
    }
    if (hints.containsKey(EncodeHintType.PDF417_COMPACTION)) {
      encoder.setCompaction(Compaction.valueOf(hints.get(EncodeHintType.PDF417_COMPACTION).toString()));
    }
    if (hints.containsKey(EncodeHintType.PDF417_DIMENSIONS)) {
      Dimensions dimensions = (Dimensions) hints.get(EncodeHintType.PDF417_DIMENSIONS);
      encoder.setDimensions(dimensions.getMaxCols(),
                            dimensions.getMinCols(),
                            dimensions.getMaxRows(),
                            dimensions.getMinRows());
    }
    if (hints.containsKey(EncodeHintType.MARGIN)) {
      margin = Integer.parseInt(hints.get(EncodeHintType.MARGIN).toString());
    }
    if (hints.containsKey(EncodeHintType.ERROR_CORRECTION)) {
      errorCorrectionLevel = Integer.parseInt(hints.get(EncodeHintType.ERROR_CORRECTION).toString());
    }
    if (hints.containsKey(EncodeHintType.CHARACTER_SET)) {
      Charset encoding = Charset.forName(hints.get(EncodeHintType.CHARACTER_SET).toString());
      encoder.setEncoding(encoding);
    }
  }

  return bitMatrixFromEncoder(encoder, contents, errorCorrectionLevel, width, height, margin);
}
 
Example #3
Source File: PDF417Writer.java    From weex with Apache License 2.0 4 votes vote down vote up
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        Map<EncodeHintType,?> hints) throws WriterException {
  if (format != BarcodeFormat.PDF_417) {
    throw new IllegalArgumentException("Can only encode PDF_417, but got " + format);
  }

  PDF417 encoder = new PDF417();
  int margin = WHITE_SPACE;
  int errorCorrectionLevel = DEFAULT_ERROR_CORRECTION_LEVEL;

  if (hints != null) {
    if (hints.containsKey(EncodeHintType.PDF417_COMPACT)) {
      encoder.setCompact(Boolean.valueOf(hints.get(EncodeHintType.PDF417_COMPACT).toString()));
    }
    if (hints.containsKey(EncodeHintType.PDF417_COMPACTION)) {
      encoder.setCompaction(Compaction.valueOf(hints.get(EncodeHintType.PDF417_COMPACTION).toString()));
    }
    if (hints.containsKey(EncodeHintType.PDF417_DIMENSIONS)) {
      Dimensions dimensions = (Dimensions) hints.get(EncodeHintType.PDF417_DIMENSIONS);
      encoder.setDimensions(dimensions.getMaxCols(),
                            dimensions.getMinCols(),
                            dimensions.getMaxRows(),
                            dimensions.getMinRows());
    }
    if (hints.containsKey(EncodeHintType.MARGIN)) {
      margin = Integer.parseInt(hints.get(EncodeHintType.MARGIN).toString());
    }
    if (hints.containsKey(EncodeHintType.ERROR_CORRECTION)) {
      errorCorrectionLevel = Integer.parseInt(hints.get(EncodeHintType.ERROR_CORRECTION).toString());
    }
    if (hints.containsKey(EncodeHintType.CHARACTER_SET)) {
      Charset encoding = Charset.forName(hints.get(EncodeHintType.CHARACTER_SET).toString());
      encoder.setEncoding(encoding);
    }
  }

  return bitMatrixFromEncoder(encoder, contents, errorCorrectionLevel, width, height, margin);
}
 
Example #4
Source File: PDF417Writer.java    From barcodescanner-lib-aar with MIT License 4 votes vote down vote up
@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        Map<EncodeHintType,?> hints) throws WriterException {
  if (format != BarcodeFormat.PDF_417) {
    throw new IllegalArgumentException("Can only encode PDF_417, but got " + format);
  }

  PDF417 encoder = new PDF417();
  int margin = WHITE_SPACE;
  int errorCorrectionLevel = DEFAULT_ERROR_CORRECTION_LEVEL;

  if (hints != null) {
    if (hints.containsKey(EncodeHintType.PDF417_COMPACT)) {
      encoder.setCompact(Boolean.valueOf(hints.get(EncodeHintType.PDF417_COMPACT).toString()));
    }
    if (hints.containsKey(EncodeHintType.PDF417_COMPACTION)) {
      encoder.setCompaction(Compaction.valueOf(hints.get(EncodeHintType.PDF417_COMPACTION).toString()));
    }
    if (hints.containsKey(EncodeHintType.PDF417_DIMENSIONS)) {
      Dimensions dimensions = (Dimensions) hints.get(EncodeHintType.PDF417_DIMENSIONS);
      encoder.setDimensions(dimensions.getMaxCols(),
                            dimensions.getMinCols(),
                            dimensions.getMaxRows(),
                            dimensions.getMinRows());
    }
    if (hints.containsKey(EncodeHintType.MARGIN)) {
      margin = Integer.parseInt(hints.get(EncodeHintType.MARGIN).toString());
    }
    if (hints.containsKey(EncodeHintType.ERROR_CORRECTION)) {
      errorCorrectionLevel = Integer.parseInt(hints.get(EncodeHintType.ERROR_CORRECTION).toString());
    }
    if (hints.containsKey(EncodeHintType.CHARACTER_SET)) {
      Charset encoding = Charset.forName(hints.get(EncodeHintType.CHARACTER_SET).toString());
      encoder.setEncoding(encoding);
    }
  }

  return bitMatrixFromEncoder(encoder, contents, errorCorrectionLevel, width, height, margin);
}