I'm having problems reading the response from the server. If I use the StoreFile parameter and access via URL the PDF looks great, but serving it up through my own server always renders the pages blank. Possibly an encoding issue?
def convertPdf(document) {
File f = new File(document)
RestBuilder rest = new RestBuilder()
def resp = rest.post("https://do.convertapi.com/Word2Pdf") {
contentType "multipart/form-data"
ApiKey = "CONFIDENTIAL"
file = f
}
InputStream istream = new ByteArrayInputStream(resp.getBody().getBytes());
File file = new File("123123.pdf");
FileOutputStream ostream = new FileOutputStream(file);
byte[] b = new byte[1024];
int num = 0;
while ((num = istream.read(b)) != -1) {
ostream.write(b, 0, num);
}
istream.close();
ostream.flush();
ostream.close();
}