create account

Implementing QR and Barcode scanner and converting result to PDF in PDF CONVERTER Android App by hiremani

View this thread on: hive.blogpeakd.comecency.com
· @hiremani · (edited)
$100.51
Implementing QR and Barcode scanner and converting result to PDF in PDF CONVERTER Android App
#### Repository
https://github.com/Swati4star/Images-to-PDF

#### PDF Convertor
https://play.google.com/store/apps/details?id=swati4star.createpdf

<blockquote>
<p>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.</p>
</blockquote>


### New Features

 [Link to Feature Request](https://github.com/Swati4star/Images-to-PDF/issues/427)
 
 ![](https://ipfs.busy.org/ipfs/QmSyksFJY7q6cBEhuzXLJjwiekRnh6mK1Hz3FyWwMKEsws) ![](https://ipfs.busy.org/ipfs/QmeetqmVjVug1Eovh2j3vqQKagcRpdydTJa2ef1mLVTEVU)
 
 ![](https://ipfs.busy.org/ipfs/QmV8yYASiXfGmv6LesYLDrKFrnDhywargNtPjF11nWM81G) ![](https://ipfs.busy.org/ipfs/QmR9t3HDg3RRxfyv5YVKXH1436dVb7yq6CN7PhiceJ1b3N)
 
- 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](https://github.com/zxing/zxing) in the task request by project owner, I considered the mobile version of [zxing](https://raw.github.com/embarkmobile/zxing-android-minimal). Here is the implementation details. Zxing is an popular QR and barcode scanner open source library.

<blockquote>
<p>ZXing ("zebra crossing") is an open-source, multi-format 1D/2D barcode image processing library implemented in Java, with ports to other languages.</p></blockquote>

Created [QrBarcodeScanFragment](https://github.com/Swati4star/Images-to-PDF/blob/master/app/src/main/java/swati4star/createpdf/fragment/QrBarcodeScanFragment.java) 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();
    }
```


		
#### GitHub Account
[Pull Request](https://github.com/Swati4star/Images-to-PDF/pull/439)
https://github.com/santoshhiremani
πŸ‘  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 41 others
properties (23)
authorhiremani
permlinkimplementing-qr-and-barcode-result-to-pdf-in-pdf-converter-android-app-1538327038296
categoryutopian-io
json_metadata{"app":"steemit/0.1","format":"markdown","image":["https://ipfs.busy.org/ipfs/QmSyksFJY7q6cBEhuzXLJjwiekRnh6mK1Hz3FyWwMKEsws","https://ipfs.busy.org/ipfs/QmeetqmVjVug1Eovh2j3vqQKagcRpdydTJa2ef1mLVTEVU","https://ipfs.busy.org/ipfs/QmV8yYASiXfGmv6LesYLDrKFrnDhywargNtPjF11nWM81G","https://ipfs.busy.org/ipfs/QmR9t3HDg3RRxfyv5YVKXH1436dVb7yq6CN7PhiceJ1b3N"],"tags":["utopian-io","development","pdf","android"],"links":["https://github.com/Swati4star/Images-to-PDF","https://play.google.com/store/apps/details?id=swati4star.createpdf","https://github.com/Swati4star/Images-to-PDF/issues/427","https://github.com/zxing/zxing","https://raw.github.com/embarkmobile/zxing-android-minimal","https://github.com/Swati4star/Images-to-PDF/blob/master/app/src/main/java/swati4star/createpdf/fragment/QrBarcodeScanFragment.java","https://github.com/Swati4star/Images-to-PDF/pull/439","https://github.com/santoshhiremani"]}
created2018-09-30 17:04:00
last_update2018-09-30 17:37:27
depth0
children5
last_payout2018-10-07 17:04:00
cashout_time1969-12-31 23:59:59
total_payout_value74.680 HBD
curator_payout_value25.831 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length5,080
author_reputation7,035,336,488,338
root_title"Implementing QR and Barcode scanner and converting result to PDF in PDF CONVERTER Android App"
beneficiaries
0.
accountutopian.pay
weight500
max_accepted_payout100,000.000 HBD
percent_hbd10,000
post_id72,365,744
net_rshares52,084,322,860,319
author_curate_reward""
vote details (105)
@codingdefined ·
$12.55
Thank you for your contribution. It's good to see you are taking the Features Request and working on it. Improving the code commenting would have been better. Since you are writing the file in a temp location, are you deleting the file after convert also before writing are you checking is the device has the required storage capacity.
 
----
Your contribution has been evaluated according to [Utopian policies and guidelines](https://join.utopian.io/guidelines), as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, [click here](https://review.utopian.io/result/3/2322222).

---- 
Need help? Write a ticket on https://support.utopian.io/. 
Chat with us on [Discord](https://discord.gg/uTyJkNm). 
[[utopian-moderator]](https://join.utopian.io/)
πŸ‘  , , , , , , , , , , , ,
properties (23)
authorcodingdefined
permlinkre-hiremani-implementing-qr-and-barcode-result-to-pdf-in-pdf-converter-android-app-1538327038296-20181001t044740346z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"links":["https://join.utopian.io/guidelines","https://review.utopian.io/result/3/2322222","https://support.utopian.io/","https://discord.gg/uTyJkNm","https://join.utopian.io/"],"app":"steemit/0.1"}
created2018-10-01 04:47:39
last_update2018-10-01 04:47:39
depth1
children2
last_payout2018-10-08 04:47:39
cashout_time1969-12-31 23:59:59
total_payout_value9.468 HBD
curator_payout_value3.077 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length832
author_reputation530,780,094,444,084
root_title"Implementing QR and Barcode scanner and converting result to PDF in PDF CONVERTER Android App"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id72,390,648
net_rshares6,335,959,873,114
author_curate_reward""
vote details (13)
@hiremani ·
Thank you for reviewing, Since we don't have implementation from converting direct text in PDF Converter so as of now we just added TEMP file just to read QR/Barcode result, every time its scans its gonna clear and add new result to it. Yes its not right approach soon i'm modifying core class to handle this operation.
properties (22)
authorhiremani
permlinkre-codingdefined-re-hiremani-implementing-qr-and-barcode-result-to-pdf-in-pdf-converter-android-app-1538327038296-20181001t064730688z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-10-01 06:47:33
last_update2018-10-01 06:47:33
depth2
children0
last_payout2018-10-08 06:47:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length319
author_reputation7,035,336,488,338
root_title"Implementing QR and Barcode scanner and converting result to PDF in PDF CONVERTER Android App"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id72,395,054
net_rshares0
@utopian-io ·
Thank you for your review, @codingdefined!

So far this week you've reviewed 1 contributions. Keep up the good work!
properties (22)
authorutopian-io
permlinkre-re-hiremani-implementing-qr-and-barcode-result-to-pdf-in-pdf-converter-android-app-1538327038296-20181001t044740346z-20181003t164040z
categoryutopian-io
json_metadata"{"app": "beem/0.20.1"}"
created2018-10-03 16:40:42
last_update2018-10-03 16:40:42
depth2
children0
last_payout2018-10-10 16:40:42
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length116
author_reputation152,955,367,999,756
root_title"Implementing QR and Barcode scanner and converting result to PDF in PDF CONVERTER Android App"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id72,558,126
net_rshares0
@steem-ua ·
#### Hi @hiremani!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
**Feel free to join our [@steem-ua Discord server](https://discord.gg/KpBNYGz)**
properties (22)
authorsteem-ua
permlinkre-implementing-qr-and-barcode-result-to-pdf-in-pdf-converter-android-app-1538327038296-20181002t031021z
categoryutopian-io
json_metadata"{"app": "beem/0.20.5"}"
created2018-10-02 03:10:24
last_update2018-10-02 03:10:24
depth1
children0
last_payout2018-10-09 03:10:24
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length287
author_reputation23,214,230,978,060
root_title"Implementing QR and Barcode scanner and converting result to PDF in PDF CONVERTER Android App"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id72,452,197
net_rshares0
@utopian-io ·
$0.02
Hey, @hiremani!

**Thanks for contributing on Utopian**.
We’re already looking forward to your next contribution!

**Get higher incentives and support Utopian.io!**
 Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via [SteemPlus](https://chrome.google.com/webstore/detail/steemplus/mjbkjgcplmaneajhcbegoffkedeankaj?hl=en) or [Steeditor](https://steeditor.app)).

**Want to chat? Join us on Discord https://discord.gg/h52nFrV.**

<a href='https://steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1'>Vote for Utopian Witness!</a>
πŸ‘  ,
properties (23)
authorutopian-io
permlinkre-implementing-qr-and-barcode-result-to-pdf-in-pdf-converter-android-app-1538327038296-20181003t015513z
categoryutopian-io
json_metadata"{"app": "beem/0.20.1"}"
created2018-10-03 01:55:15
last_update2018-10-03 01:55:15
depth1
children0
last_payout2018-10-10 01:55:15
cashout_time1969-12-31 23:59:59
total_payout_value0.019 HBD
curator_payout_value0.005 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length590
author_reputation152,955,367,999,756
root_title"Implementing QR and Barcode scanner and converting result to PDF in PDF CONVERTER Android App"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id72,515,205
net_rshares13,643,831,616
author_curate_reward""
vote details (2)