Kontrol cihazımda pdf açmak ve tarayıcıya aktarmak istiyorum. Açık kodları kullanmazsam bu kod çalışır. Ancak, dosya adından sonra # search = "java" gibi açık bir parametre kullanmam gerekiyor. Açık parametreleri kullanmak, bir url ise iyi çalışır ancak dosyayı açmak için adobe açık parametrelerini kullanabileceğim bir yol var.
Kullandığım kod:
private static final String DOCUMENT_LOCATION = "C:\\testPDF\\mytest.pdf#search=" + "\"" + "java" + "\"";
@RequestMapping(method=RequestMethod.GET)
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//set some response headers
response.setContentType("application/pdf");
InputStream in = new FileInputStream(DOCUMENT_LOCATION);
OutputStream out = response.getOutputStream();
//Copy the bits from instream to outstream
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
in.close();
}