I have to write an application to render PDF documents with Thymeleaf. These documents are stored in a remote server and are accesed through HTTP.
I know it is possible to render PDF documents, when they are stored in the project´s ressource folder. But I don`t want to download them.
Is there any possible way?
I am receiving the file with the following code:
URL url = new URL("http://10.139.1.240:8080/document.pdf");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
if (connection.getResponseCode() == 200) {
try (InputStreamReader streamReader = new InputStreamReader(connection.getInputStream());
BufferedReader br = new BufferedReader(streamReader);
Stream<String> lines = br.lines()) {
Desktop.getDesktop().browse(url.toURI());
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}