Skip to content
Advertisement

How to open secific range of pages in pdf instead of whole pdf

How to modify the following code to open specific range of pages within the pdf for example from page 5 to 30 instead of opening the whole pdf. Thanks in advance

 IOExcept {touch = new
ZoomableImageView(Part1Activity.this);
linear1.addView(touch);
File file = new File(getCacheDir(), "quran_01.pdf"); if (!file.exists()) { try { InputStream asset = getAssets().open("quran_01.pdf"); FileOutputStream output = null; output = new FileOutputStream(file); final byte[] buffer = new byte[1024]; int size; while ((size = asset.read(buffer)) != -1) { output.write(buffer, 0, size); } asset.close(); output.close(); } catch (IOException e) { e.printStackTrace(); } }
try {
renderer = new android.graphics.pdf.PdfRenderer(new ParcelFileDescriptor(ParcelFileDescriptor.open(new java.io.File(file.getAbsolutePath()), ParcelFileDescriptor.MODE_READ_ONLY)));
android.graphics.pdf.PdfRenderer.Page page = renderer.openPage((int)_position);

Bitmap mBitmap = Bitmap.createBitmap((int)getDip(page.getWidth()), (int)getDip(page.getHeight()), Bitmap.Config.ARGB_8888);

page.render(mBitmap, null, null, android.graphics.pdf.PdfRenderer.Page.RENDER_MODE_FOR_DISPLAY);

touch.setImageBitmap(mBitmap);

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

Advertisement

Answer

You can’t modify a third party tool, where the option to change the site range programmatically isn’t given. Thus, you can’t use external Viewer without Endpoints to handle.

I recommend to watch for app internal PDF Viewer/Tools that you can modify by code.

Take a look at this post, it can help you to work around or use the mentioned open source tools. Cheers!

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement