public byte[] downloadDocument(PackageId packageId, String documentId) throws EslException { String path = template .urlFor(UrlTemplate.PDF_PATH) .replace("{packageId}", packageId.getId()) .replace("{documentId}", documentId) .build(); try { return client.getBytesAsOctetStream(path).getContents(); } catch (RequestException e) { throw new EslServerException("Could not download the pdf document.", e); } catch (Exception e) { throw new EslException("Could not download the pdf document.", e); } }