<p>You can use this code first download the PDF file then read the text with apache lib. you need to add some jar manually. 
you need to set your local pdf file address which is by defualt "download.pdf".</p>

<pre><code>import com.gnostice.pdfone.PdfDocument;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.text.PDFTextStripper;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.ConnectException;
import java.net.URL;
import java.net.URLConnection;


public class LoadDocumentFromURL {
public static void main(String[] args) throws IOException {

        URL url1 = new URL("https://arxiv.org/pdf/1811.06933.pdf");
        byte[] ba1 = new byte[1024];
        int baLength;
        FileOutputStream fos1 = new FileOutputStream("download.pdf");
        try {
            // Contacting the URL
            // System.out.print("Connecting to " + url1.toString() + " ... ");
            URLConnection urlConn = url1.openConnection();
            // Checking whether the URL contains a PDF
            if (!urlConn.getContentType().equalsIgnoreCase("application/pdf")) {
                System.out.println("FAILED.\n[Sorry. This is not a PDF.]");
            } else {
                try {
                    // Read the PDF from the URL and save to a local file
                    InputStream is1 = url1.openStream();
                    while ((baLength = is1.read(ba1)) != -1) {
                        fos1.write(ba1, 0, baLength);
                    }
                    fos1.flush();
                    fos1.close();
                    is1.close();
                    // Load the PDF document and display its page count
                    //System.out.print("DONE.\nProcessing the PDF ... ");
                    PdfDocument doc = new PdfDocument();
                    try {
                        doc.load("download.pdf");
                        // System.out.println("DONE.\nNumber of pages in the PDF is " + doc.getPageCount());
                        // System.out.println(doc.getAuthor());
                        // System.out.println(doc.getKeywords());
                        // System.out.println(doc.toString());
                        doc.close();
                    } catch (Exception e) {
                        System.out.println("FAILED.\n[" + e.getMessage() + "]");
                    }
                } catch (ConnectException ce) {
                    //System.out.println("FAILED.\n[" + ce.getMessage() + "]\n");
                }
            }
        } catch (NullPointerException npe) {
            //System.out.println("FAILED.\n[" + npe.getMessage() + "]\n");
        }
        File file = new File("your local pdf file address which is download.pdf");
        PDDocument document = PDDocument.load(file);
        PDFTextStripper pdfStripper = new PDFTextStripper();
        String text = pdfStripper.getText(document);
        System.out.println(text);
        document.close();
    }
}
</code></pre>
Parse text from Pdf, txt, or docx file from URL without downloading it in Java 8
<p>I need to be able to parse the text contained in a file online with a given url, i.e. <code>http://website.com/document.pdf</code>.</p>

<p>I am making a search engine which basically can tell me if the searched word is in some file online, and retrieve the file's URL, so I don't need to download the file but to just read it.</p>

<p>I was looking for a way and found something with <code>InputStream</code> and <code>OpenConnection</code> but didn't managed to actually do it.</p>

<p>I am using jsoup in order to crawl around a website in order to retrieve the URLs, and I was trying to parse it with a Jsoup method, but it does not work.</p>

<p>So what is the best way to do this?</p>

<p>EDIT:</p>

<p>I want to be able to do something like this:</p>

<pre><code>File in = new File("http://website.com/document.pdf");
Document doc = Jsoup.parse(in, "UTF-8");
System.out.println(doc.toString());
</code></pre>