Note that there are some explanatory texts on larger screens.

plurals
  1. POHigh resolution screen shot in Android
    primarykey
    data
    text
    <p>Is there any way to get a <strong>high resolution</strong> screen shot of a certain view in an activity. </p> <p>I want to convert html content of my webview to PDF. For that I tried to take screen shot of the webview content and then converted it to PDF using itext. The resulted PDF is not in much more clarity. </p> <p>My code:</p> <pre><code> protected void takeimg() { Picture picture = mWebView.capturePicture(); Bitmap b = Bitmap.createBitmap(picture.getWidth(), picture.getHeight(), Bitmap.Config.ARGB_8888); Canvas c = new Canvas(b); picture.draw(c); // byte[] bt = b.getNinePatchChunk(); // Bitmap b; // View v1 = mWebView.getRootView(); // v1.setDrawingCacheEnabled(true); // b = Bitmap.createBitmap(v1.getDrawingCache()); // v1.setDrawingCacheEnabled(false); FileOutputStream fos = null; try { File root = new File(Environment.getExternalStorageDirectory(), "Sample"); if (!root.exists()) { root.mkdir(); } String sdcardhtmlpath = root.getPath().toString() + "/" + "temp_1.png"; fos = new FileOutputStream(sdcardhtmlpath); // fos = openFileOutput("samsp_1.jpg", MODE_WORLD_WRITEABLE); if (fos != null) { b.compress(Bitmap.CompressFormat.PNG, 100, fos); // fos.write(bt); fos.close(); } } catch (Exception e) { Log.e("takeimg", e.toString()); e.printStackTrace(); } } protected void pdfimg() { Document mydoc = new Document(PageSize.A3); try { File root = new File(Environment.getExternalStorageDirectory(), "Sample"); if (!root.exists()) { root.mkdir(); } String sdcardhtmlpath = root.getPath().toString() + "/"; mydoc.setMargins(0, 0, 0, 0); PdfWriter.getInstance(mydoc, new FileOutputStream(sdcardhtmlpath + PDFfilename)); mydoc.open(); Image image1 = Image.getInstance(sdcardhtmlpath + "temp_1.jpg"); image1.scalePercent(95f); mydoc.add(image1); // mydoc.newPage(); mydoc.close(); } catch (Exception e) { Log.e("pdi name", e.toString()); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload