I am Converting docx or doc to PDF in android using apache poi library -
I used this dependency in my gradle file -
implementation "fr.opensagres.xdocreport:org.apache.poi.xwpf.converter.pdf:1.0.5"
and this is code
import androidx.appcompat.app.AppCompatActivity
import kotlinx.android.synthetic.main.activity_main.*
import org.apache.poi.xwpf.converter.pdf.PdfConverter
import org.apache.poi.xwpf.converter.pdf.PdfOptions
import org.apache.poi.xwpf.usermodel.XWPFDocument
import java.io.*
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
convertPDf.setOnClickListener {
//1 st
try {
val doc: InputStream = FileInputStream(File("storage/emulated/0/WhatsApp/Media/WhatsApp Documents/Resume.docx"))
val document = XWPFDocument(doc)
val options: PdfOptions = PdfOptions.create()
val out: OutputStream = FileOutputStream(File("/storage/emulated/0/Movies/file-Sample-ConvertedToPDF.pdf"))
PdfConverter.getInstance().convert(document, out, options)
} catch (ex: FileNotFoundException) {
Log.i("printer", "exception in converting pdf =>${ex.message}")
} catch (ex: IOException) {
Log.i("printer", "exception in converting pdf =>${ex.message}")
}
}
but it gives me this error
E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.myapplication, PID: 20719 java.lang.NoClassDefFoundError: Failed resolution of: Ljava/awt/Color;
is any other way to resolve this or way to converting doc to pdf in android