Knowledge Base - Send pdf page by e-mail

To send a PDF page via e-mail, you can render the page to a bitmap using the below code, save and send. 

Document doc = new Document();
if( doc.Open(m_path, null) == 0 ) {
int iw = thumb_width;
int ih = thumb_height;
Page page = doc.GetPage0();

Bitmap bmp = Bitmap.createBitmap( iw, ih, Bitmap.Config.ARGB_8888 );
bmp.eraseColor(0);

float w = doc.GetPageWidth(0);
float h = doc.GetPageHeight(0);
float ratiox = iw/w;
float ratioy = ih/h;
if( ratiox > ratioy ) ratiox = ratioy;
Matrix mat = new Matrix( ratiox, -ratiox, (iw - w * ratiox)/2, (ih + h * ratiox)/2 );
page.RenderToBmp(bmp, mat);
mat.Destroy();

try {
FileOutputStream fos = new FileOutputStream(pictureFile); //pictureFile the path of the bitmap to pass to send intent
bmp.compress(Bitmap.CompressFormat.PNG, 90, fos);
fos.close();
} catch (Exception e) {
e.getMessage();
}
bmp.recycle();
page.Close();
doc.Close(); 
//send pictureFile by mail

Or if you have a premium license, you can extract the PDF page(s) into a separate PDF, save and send. 

    Document document = new Document();
if(document.Open(path, password) == 0) {
Document new_doc = new Document();
new_doc.Create( destFile ); //destFile the path of the destination file to pass to send intent
new_doc.Open(destFile, null);
new_doc.SetCache( file_cache );

Document.ImportContext ctx = new_doc.ImportStart(document);
boolean result = false;
for (int i = 0 ; i < mPages.length ; i++) //mPages array containing the page numbers to send
result = new_doc.ImportPage(ctx, mPages[i].getPageNum() - 1, i);
ctx.Destroy();

new_doc.Save();
new_doc.Close();

document.Close();
if(resul)
//send destFile by mail
}
Applies To

RadaeePDF SDK for Android

Details

Created : 2016-12-12 11:53:17, Last Modified : 2016-12-12 12:12:06