Hi,
I need to add image on PDF file, I have used the code link:-
Document pdf_doc = new Document();
pdf_doc.Create(Environment.getExternalStorageDirectory() + getString(R.string.teli_dir) + "/test.pdf");
int page_no = 1;
for (File f: allFiles) {
if (f.getName().contains("jpg")){
Page page = pdf_doc.NewPage(page_no++,210,297);
BitmapFactory.Options bmpOptions = new BitmapFactory.Options();
bmpOptions.inJustDecodeBounds = true;
bmp = BitmapFactory.decodeFile(f.getAbsolutePath(), bmpOptions);
PageContent pageContent = new PageContent();
pageContent.Create();
pageContent.GSSave();
com.radaee.pdf.Matrix mat = new com.radaee.pdf.Matrix(250, 250, 0, 0);
pageContent.GSSave();
pageContent.GSSetMatrix(mat);
Document.DocImage docimage = pdf_doc.NewImage(bmp, true);
ResImage rimage = page.AddResImage(docimage);
pageContent.GSSave();
mat.Destroy();
pageContent.DrawImage(rimage);
pageContent.GSRestore();
page.AddContent(pageContent, false);
pageContent.Destroy();
page.Close();
}
}
pdf_doc.Save();
pdf_doc.Close();
but when i open and load existing file on Document then application is going to crash.
Please check this code.
Thanks