0

This is the qr-code generator, I put on String qrCodeData to try access the storage of my phone and open up a file, but it doesnt work. Turns out the generated qr code only gives the link.

public class QRCode {

    public static void main(String[] args) {
       try {
            String qrCodeData = "Device storage/Download/japanese/Mastering_Kanji_1500.pdf";
            String filePath = "D:\\QR code project\\Generated QR codes\\qr.png";
            String charset = "UTF-8"; // or "ISO-8859-1"
            Map < EncodeHintType, ErrorCorrectionLevel > hintMap = new HashMap < EncodeHintType, ErrorCorrectionLevel > ();
            hintMap.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L);
            BitMatrix matrix = new MultiFormatWriter().encode(
                new String(qrCodeData.getBytes(charset), charset),
                BarcodeFormat.QR_CODE, 200, 200, hintMap);
            MatrixToImageWriter.writeToFile(matrix, filePath.substring(filePath
                .lastIndexOf('.') + 1), new File(filePath));
            System.out.println("QR Code image created successfully! and stored at location"+filePath);
        } catch (Exception e) {
            System.err.println(e);
        }
    }    
}
Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373

1 Answers1

0

We are able to view and manipulate PDF files via the PDFBox library.

Android version.

We may also use MuPDF. It has an Android version.

Interpret the received link as a file or download it to storage, then proceed to interface with PDFBox library.

Note that file downloading and access on Android should now be done via Room interface or SQLite as recommended by Google.

Hope this helps.

mindoverflow
  • 730
  • 4
  • 13