Repository
https://github.com/Swati4star/Images-to-PDF
PDF Convertor
https://play.google.com/store/apps/details?id=swati4star.createpdf
PDF CONVERTER is an easy to use application to convert Images to PDF. This is basically an images to PDF Converter. The simplicity of this app makes it an ultimate PDF Converter for your device.
New Features
- What feature(s) did you add?
Added new feature to scan QR or Barcodes and convert the result in PF format. - How did you implement it/them?
As mentioned xzing in the task request by project owner, I considered the mobile version of zxing. Here is the implementation details. Zxing is an popular QR and barcode scanner open source library.
ZXing ("zebra crossing") is an open-source, multi-format 1D/2D barcode image processing library implemented in Java, with ports to other languages.
Created QrBarcodeScanFragment frament which will open camera based on user selection i. e. QR or Barcode. The scan result captured was initially written to a TEMP text file and later converted to PDF using existing implementation of the app.
File mDir = getContext().getCacheDir();
File mTempFile = new File(mDir.getPath() + "/" + mTempFileName);
PrintWriter mWriter = null;
try {
mWriter = new PrintWriter(mTempFile);
mWriter.print("");
mWriter.append("Result : " + result.getContents());
mWriter.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
Uri uri = Uri.fromFile(mTempFile);
resultToTextPdf(uri);
Methods to open Camera to scan QR and Barcodes.
/**
* Open camera for Barcode Scan
*/
public void openCameraForBarcode() {
IntentIntegrator integrator = IntentIntegrator.forSupportFragment(this);
// use forSupportFragment or forFragment method to use fragments instead of activity
integrator.setDesiredBarcodeFormats(IntentIntegrator.ONE_D_CODE_TYPES);
integrator.setPrompt(mActivity.getString(R.string.scan_barcode));
integrator.setScanningRectangle(1000, 450);
integrator.setResultDisplayDuration(0); // milliseconds to display result on screen after scan
integrator.setCameraId(0); // Use a specific camera of the device
integrator.initiateScan();
}
/**
* Open camera for QRCode Scan
*/
public void openCameraForQrcode() {
IntentIntegrator integrator = IntentIntegrator.forSupportFragment(this);
// use forSupportFragment or forFragment method to use fragments instead of activity
integrator.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE_TYPES);
integrator.setPrompt(mActivity.getString(R.string.scan_qrcode));
integrator.setScanningRectangle(600, 600);
integrator.setResultDisplayDuration(0); // milliseconds to display result on screen after scan
integrator.setCameraId(0); // Use a specific camera of the device
integrator.initiateScan();
}
Converting text to PDF and preview..
/**
* Generate Result to PDF
* @param uri
*/
private void resultToTextPdf(Uri uri) {
new MaterialDialog.Builder(getActivity())
.title(R.string.creating_pdf)
.content(R.string.enter_file_name)
.input(getString(R.string.example), null, (dialog, input) -> {
if (StringUtils.isEmpty(input)) {
showSnackbar(getActivity(), R.string.snackbar_name_not_blank);
} else {
final String inputName = input.toString();
if (!mFileUtils.isFileExist(inputName + getString(R.string.pdf_ext))) {
createPdf(inputName, uri);
} else {
MaterialDialog.Builder builder = createOverwriteDialog(getActivity());
builder.onPositive((dialog12, which) -> createPdf(inputName, uri))
.onNegative((dialog1, which) -> resultToTextPdf(uri))
.show();
}
}
})
.show();
}