Android library to convert Html from strings into Pdf files.
Feel free to fork and use it.
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
implementation 'com.github.LucasFsc:Html2Pdf:0.2-beta'
In your MainActivity instantiate the converter class and pass the parameters:
class MainActivity : AppCompatActivity(), Html2Pdf.OnCompleteConversion /* Callback */ {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
//Impl example
val converter = Html2Pdf.Companion.Builder()
.context(this)
.html("<p> Your awesome HTML string here! </p>")
.file(File(URI("Your Pdf file URI")))
.build()
//can be called with a callback to warn the user, share file...
converter.convertToPdf(this)
//or without a callback
converter.convertToPdf()
}
override fun onSuccess() {
//do your thing
}
override fun onFailed() {
//do your thing
}
}