How to convert Image to PDF?

I would suggest you to use iText pdf library. Here is the gradle dependency: implementation ‘com.itextpdf:itextg:5.5.10’ Document document = new Document(); String directoryPath = android.os.Environment.getExternalStorageDirectory().toString(); PdfWriter.getInstance(document, new FileOutputStream(directoryPath + “/example.pdf”)); // Change pdf’s name. document.open(); Image image = Image.getInstance(directoryPath + “https://stackoverflow.com/” + “example.jpg”); // Change image’s name and extension. float scaler = ((document.getPageSize().getWidth() – document.leftMargin() … Read more

Android Bitmap to Base64 String

use following method to convert bitmap to byte array: ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream); byte[] byteArray = byteArrayOutputStream .toByteArray(); to encode base64 from byte array use following method String encoded = Base64.encodeToString(byteArray, Base64.DEFAULT);