HTML to PDF convertor for Android

Overview

HTML to PDF Convertor

A simple HTML to PDF convertor for Android

Download

Add mavenCentral() repository in project's build.gradle

allprojects {
    repositories {
        // Possibly other repositories
        mavenCentral()
    }
}

Add dependency in module's build.gradle

dependencies {
    // Possibly other dependencies
    // Replace the <latest-version> with actual latest version
    implementation 'io.github.nvest-solutions:html-to-pdf-convertor:<latest-version>'
}

Usage

Create an instance of HtmlToPdfConvertor class

val htmlToPdfConvertor = HtmlToPdfConvertor(context)

Set optional base URL

htmlToPdfConvertor.setBaseUrl("file:///android_asset/images/") // is null by default

Start the conversion by calling convert function

htmlToPdfConvertor.convert(
  pdfLocation = pdfLocation, // the file location where pdf should be saved
  htmlString = htmlString, // the HTML string to be converted
  onPdfGenerationFailed = { exception -> // something went wrong, handle the exception (this param is optional) 
      exception.printStackTrace()
  },
  onPdfGenerated = { pdfFile -> // pdf was generated, do whatever you want with it
      openPdf(pdfFile)
  })

Storage permission is required to save pdf file on storage

Checkout sample code, also sample HTML and PDF

You might also like...
Pdf Extractor - Covert array list of object to pdf table
Pdf Extractor - Covert array list of object to pdf table

Pdf Extractor - Covert array list of object to pdf table

Compose-html - An Android library which provides HTML support for Jetpack Compose texts
Compose-html - An Android library which provides HTML support for Jetpack Compose texts

HtmlCompose An Android library which provides HTML support for Jetpack Compose t

[] A fast PDF reader component for Android development
[] A fast PDF reader component for Android development

This project is no longer maintained. You can find a good replacement here, which is a fork relying on Pdfium instead of Vudroid/MuPDF for decoding PD

Pdf Viewer library for Android

This is a packaging of the project "Android PDF Viewer" (http://andpdf.sourceforge.net/) into a reusable library to make PDF viewing easier from withi

Simple library to generate and view PDF in Android
Simple library to generate and view PDF in Android

PDFCreatorAndroid Simple library to generate and view PDF in Android A simple library to create and view PDF with zero dependency Or native code. Add

An ebook reader application supporting PDF, DjVu, EPUB, FB2 and many more formats, running on Cervantes, Kindle, Kobo, PocketBook and Android devices
An ebook reader application supporting PDF, DjVu, EPUB, FB2 and many more formats, running on Cervantes, Kindle, Kobo, PocketBook and Android devices

KOReader is a document viewer primarily aimed at e-ink readers. Download • Wiki • Developer docs Main features portable: runs on embedded devices (Cer

 Green Pass: PDF Reader (unofficial) Android App
Green Pass: PDF Reader (unofficial) Android App

Green Pass: PDF Reader (unofficial) Android App Offers a convenient access to a single one-sided PDF document and its QR code (if present in the docum

A simple Pdf document viewer 💼
A simple Pdf document viewer 💼

Pdf Viewer Plus Screenshots Main Page Main Page Cyanea Permissions and privacy This app does not collect any data. The following permissions are requi

Sample app for Amazon_IAP base on Amazon_IAP_eBook.pdf

AmazonIAP Sample app for Amazon_IAP base on Amazon_IAP_eBook.pdf You can download IAP

With the Help of this libray you can pic image from camera, gallery, it's support image cropping as well and you can pic PDF

FilePicker This project aims to provide an ultimate and flexible image picking from Gallery, Camera and cropping experience as well as PDF picking fro

Deprecated in favour of https://developer.android.com/reference/android/support/v4/view/animation/PathInterpolatorCompat.html

Deprecated: use https://developer.android.com/reference/android/support/v4/view/animation/PathInterpolatorCompat.html instead. android-cubic-bezier-in

****. Use the native and support library variants instead - https://developer.android.com/guide/topics/ui/look-and-feel/fonts-in-xml.html. An android library that makes it easy to add custom fonts to edittexts and textviews

Add to your project Add this line to your dependencies in build.gradle compile 'in.workarounds.typography:typography:0.0.8' Using the views There are

MarkdownView is an Android webview with the capablity of loading Markdown text or file and display it as HTML, it uses MarkdownJ and extends Android webview.
MarkdownView is an Android webview with the capablity of loading Markdown text or file and display it as HTML, it uses MarkdownJ and extends Android webview.

About MarkdownView (Markdown For Android) is an Android library that helps you display Markdown text or files (local/remote) as formatted HTML, and st

MarkdownView is an Android webview with the capablity of loading Markdown text or file and display it as HTML, it uses MarkdownJ and extends Android webview.
MarkdownView is an Android webview with the capablity of loading Markdown text or file and display it as HTML, it uses MarkdownJ and extends Android webview.

MarkdownView is an Android webview with the capablity of loading Markdown text or file and display it as HTML, it uses MarkdownJ and extends Android webview.

A list of most useful resources for designing android apps such as all material colors and dimens, 180 Gradient background + html, social, flat, fluent, metro colors.

Timer UI Login UI Fitness UI Material-Resources-Library A list of most useful resources for designing android apps such as all material colors and dim

Build valid HTML for Android TextView
Build valid HTML for Android TextView

HTML Builder Build valid HTML for Android TextView. Description There is a lovely method on the android.text.Html class, fromHtml(), that converts HTM

A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.

Ionic Ionic is an open source app development toolkit for building modern, fast, top-quality cross-platform native and Progressive Web Apps from a sin

A Android Web IDE supports code auto-completion and highlight, plugin (Supports Html, Css, JS, Json, Php etc)

WebDevOps A Android Web IDE supports code auto-completion and highlight, plugin (Supports Html, Css, JS, Json, Php etc) Join us QQ group number: 10314

Bottom Navigation widget component inspired by the Google Material Design Guidelines at https://www.google.com/design/spec/components/bottom-navigation.html
Bottom Navigation widget component inspired by the Google Material Design Guidelines at https://www.google.com/design/spec/components/bottom-navigation.html

Material Bottom Navigation Library Lightweight Bottom Navigation library component inspired by the Google Material Design Guidelines at https://www.go

Comments
  • how to load image from drawable ?

    how to load image from drawable ?

    hi,

    i have to load image from drawable in below code of HTML.

    how can i load?

    please help!!!!!

    Thanks in adavance

    opened by sw-tt-kushanshah 2
  • Dynamic content in HTML is not found in created PDF

    Dynamic content in HTML is not found in created PDF

    I have a Table with headers "Name" & "Age". There are dynamic entries in the above table.

    When running HTML code displays the Table with 2 entries. When generating a pdf, the table is empty.

    Below is the HTML code.

    <!DOCTYPE html>
    <html>
       <head>
          <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
       <body>
          <table>
             <thead>
                <tr>
                   <td>Name</td>
                   <td>Age</td>
                </tr>
             </thead>
             <tbody id="myTable"></tbody>
          </table>
       </body>
       <script>
          $(document).ready(function(){
            $("button").click(function(){
              $("h1, h2, p").addClass("blue");
              $("div").addClass("important");
            });
          
          
            var arra = [{name:'asin',age:50},{name:'vmj',age:80}]
            var temopHtml='';
          
            for(i=0;i<arra.length;i++){
            console.log(arra[i])
            var el = '<tr><td>'+arra[i].name+'</td><td>'+arra[i].age+'</td></tr>'
            temopHtml = temopHtml + el
            }
          
            $('#myTable').append(temopHtml);
          });
       </script>
       <style>
          .important {
          font-weight: bold;
          font-size: xx-large;
          }
          .blue {
          color: blue;
          }
       </style>
       </head>
    </html>
    
    opened by rulfox 1
  • Converted PDF file saved with only one blank page

    Converted PDF file saved with only one blank page

    opened by akash55 1
Releases(1.1.0)
  • 1.1.0(Dec 10, 2022)

    What's Changed

    • Added javascript enable/ disable API by @mddanishansari in https://github.com/mddanishansari/html-to-pdf-convertor/pull/6
    • Change package name
    • Change gradle dependency groupId

    Full Changelog: https://github.com/mddanishansari/html-to-pdf-convertor/compare/1.0.0...1.1.0

    Source code(tar.gz)
    Source code(zip)
  • 1.0.0(Jun 21, 2021)

Owner
MD Danish Ansari
MD Danish Ansari
Pdf Extractor - Covert array list of object to pdf table

Pdf Extractor - Covert array list of object to pdf table

Mostafa Gad 8 Apr 3, 2022
An ebook reader application supporting PDF, DjVu, EPUB, FB2 and many more formats, running on Cervantes, Kindle, Kobo, PocketBook and Android devices

KOReader is a document viewer primarily aimed at e-ink readers. Download • Wiki • Developer docs Main features portable: runs on embedded devices (Cer

KOReader Community 12k Jan 4, 2023
Green Pass: PDF Reader (unofficial) Android App

Green Pass: PDF Reader (unofficial) Android App Offers a convenient access to a single one-sided PDF document and its QR code (if present in the docum

Michael Troger 32 Dec 31, 2022
A simple Pdf document viewer 💼

Pdf Viewer Plus Screenshots Main Page Main Page Cyanea Permissions and privacy This app does not collect any data. The following permissions are requi

gokul 332 Dec 7, 2022
Document Viewer is a highly customizable document viewer for Android.

Document Viewer Document Viewer is a highly customizable document viewer for Android. Supports the following formats: PDF DjVu EPUB XPS (OpenXPS) CBZ

Sufficiently Secure 492 Jan 8, 2023
Librera Reader is an e-book reader for Android devices;

Librera Reader is an e-book reader for Android devices; it supports the following formats: PDF, EPUB, EPUB3, MOBI, DjVu, FB2, TXT, RTF, AZW, AZW3, HTML, CBZ, CBR, DOC, DOCX, and OPDS Catalogs

Ivan Ivanenko 1.3k Jan 2, 2023
OpenNoteScanner - Android application for scanning and manipulating handwritten notes and documents.

OpenNoteScanner This little application provides a way on scanning handwritten notes and printed documents. It automatically detect the edge of the pa

Claudemir Todo Bom 1.2k Jan 1, 2023
HTML to PDF convertor for Android

HTML to PDF Convertor A simple HTML to PDF convertor for Android Download Add mavenCentral() repository in project's build.gradle allprojects { re

MD Danish Ansari 48 Jan 2, 2023
A Lightweight PDF Viewer Android library which only occupies around 125kb while most of the Pdf viewer occupies up to 16MB space.

Pdf Viewer For Android A Simple PDF Viewer library which only occupies around 125kb while most of the Pdf viewer occupies upto 16MB space. How to inte

Rajat 362 Dec 29, 2022
Pdf Reader: Read text in PDF with Text to Speech

PDF Reader PDF Reader Read text in PDF with Text to Speech APK Link Here | App D

Rushikesh Suryawanshi 0 Jan 21, 2022