You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So I'm not sure this is actually a bug, but I can't get the API working using java (groovy/grails to be precise). I use the java HttpClient and MultipartEntity to create the http request, containing the remoteURL of the page I want to make into a PDF. The API do gives me what seems to be a PDF file, but it cannot be opened, neither by a local pdf viewer or the browser, both telling me that the file seems to be damaged or in an unsupported format.
Here is the code I use :
static def execute(def apiURL){
def httpClient = HttpClients.createDefault()
def request = new HttpPost(apiURL)
MultipartEntityBuilder builder = MultipartEntityBuilder.create()
builder.addTextBody("remoteURL", 'https://google.com')
builder.addTextBody("marginTop", '0')
builder.addTextBody("marginBottom", '0')
builder.addTextBody("marginLeft", '0')
builder.addTextBody("marginRight", '0')
HttpEntity multipart = builder.build()
request.setEntity(multipart)
def response = httpClient.execute(request)
BufferedReader rd = new BufferedReader(
new InputStreamReader(response.getEntity().getContent()))
StringBuffer result = new StringBuffer()
String line = ""
while ((line = rd.readLine()) != null) {
result.append(line)
}
return result
}
I do get a StringBuffer starting with
"%PDF-1.4%����1 0 obj<</Creator (Chromium)/Producer (Skia/PDF m74)/CreationDate (D:20190510164315+00'00')..."
that's why I say it looks like a PDF file.
I am sure the API works fine, since when I do a curl request, from a terminal or from my java project, I do have a proper PDF file. I can't use the curl request in my code, though, because it download the file into my project, instead of giving it as a variable I can easily use and convert as base64.
I am coming here for help since I can't figure out if the problem is from my request or the API, so if anyone has an idea, that would be great
The text was updated successfully, but these errors were encountered:
Hello,
So I'm not sure this is actually a bug, but I can't get the API working using java (groovy/grails to be precise). I use the java HttpClient and MultipartEntity to create the http request, containing the remoteURL of the page I want to make into a PDF. The API do gives me what seems to be a PDF file, but it cannot be opened, neither by a local pdf viewer or the browser, both telling me that the file seems to be damaged or in an unsupported format.
Here is the code I use :
I do get a StringBuffer starting with
"%PDF-1.4%����1 0 obj<</Creator (Chromium)/Producer (Skia/PDF m74)/CreationDate (D:20190510164315+00'00')..."
that's why I say it looks like a PDF file.
I am sure the API works fine, since when I do a curl request, from a terminal or from my java project, I do have a proper PDF file. I can't use the curl request in my code, though, because it download the file into my project, instead of giving it as a variable I can easily use and convert as base64.
I am coming here for help since I can't figure out if the problem is from my request or the API, so if anyone has an idea, that would be great
The text was updated successfully, but these errors were encountered: