3

hi this is the code for displaying wibview then taking webview screenshot. the image is storing into sd card. Now i want to convert it without storing. what iam asking means i want to convert that screenshot into PDF format then i want to take printout by connecting WiFi. Please help me.

import java.io.FileOutputStream;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Picture;
import android.os.Bundle;
import android.view.Menu;
import android.webkit.WebView;
import android.webkit.WebViewClient;

 public class MainActivity extends Activity {

WebView w ;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
w = new WebView(this);
w.setWebViewClient(new WebViewClient()
{
       public void onPageFinished(WebView view, String url)
       {
               Picture picture = view.capturePicture();
               Bitmap  b = Bitmap.createBitmap( picture.getWidth(),
               picture.getHeight(), Bitmap.Config.ARGB_8888);
               Canvas c = new Canvas( b );

               picture.draw( c );
               FileOutputStream fos = null;
               try {

                   fos = new FileOutputStream( "mnt/sdcard/yahoo.jpg" );
                       if ( fos != null )
                       {
                           b.compress(Bitmap.CompressFormat.JPEG, 100, fos);

                           fos.close();
                       }
                   }
              catch( Exception e )
              {

              }
     }
 });

setContentView(w);
w.loadUrl("http://google.com");
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
user3374790
  • 227
  • 3
  • 13
  • see this link hope it's helpful - http://stackoverflow.com/questions/12315037/how-to-convert-image-file-to-a-pdf-file-in-android –  Mar 31 '14 at 07:17
  • if you would like to use itext, see this - http://stackoverflow.com/questions/16438067/how-to-convert-images-to-pdf-using-itext?lq=1 – Spire.XLS API Feb 04 '15 at 06:55

0 Answers0