Reading or opening a pdf file using iText in android

I am new to Android app development. using iText I created a PDF file n on this created file now I want to read this PDF file. how to open or read a pdf file using iText.

Examples will be noticeable.

thenx in advance ..... !!!

which is the best library for rendering a pdf file .. ???? JPedal / iText / gnujpdf or any other ..... ?????

+4
source share
2 answers

Actually, iText is intended only for creating PDF, it does not contain part of the viewing. So, you need to choose another library. You can follow the link provided by Ajarahmed to find useful libraries.

+7
source

You can create your own PDF viewer using iText, you can get images for a specific page and just display this image as a scroll.
But to use this approach, you will need to implement an effective cache and set a threshold for certain pages that will be executed upon initial launch and gradually.
Here is a link to help you:

public void makeImageFromPDF throws DocumentException, IOException { String INPUTFILE = Environment.getExternalStorageDirectory() .getAbsolutePath()+"/YOUR_DIRECTORY/inputFile.pdf"; String OUTPUTFILE = Environment.getExternalStorageDirectory() .getAbsolutePath()+"/YOUR_DIRECTORY/outputFile.pdf"; Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(OUTPUTFILE)); document.open(); PdfReader reader = new PdfReader(INPUTFILE); int n = reader.getNumberOfPages(); PdfImportedPage page; // Traversing through all the pages for (int i = 1; i <= n; i++) { page = writer.getImportedPage(reader, i); Image instance = Image.getInstance(page); //Save a specific page threshold for displaying in a scroll view inside your App } document.close(); } 

You can also use this link as a link:
Reading a pdf file using the iText library
Hope this helps.

+2
source

Source: https://habr.com/ru/post/1396596/


All Articles