Hello - I am calling some ASCII code via and API and trying to convert this to PDF. The attached sequence seems to be working fine but when the PDF is saved down it is blank when opened. Would anyone know what I’m missing here?
As far I can tell, the original text is wrong: the string should be read as binary and not text in the first place. Are you downloading the text as binary?
If the file is good, could you please zip it and share the resulting archive?
EDIT: I’m also quite confuse: I have not much knowledge in that matter but the “text” appear to be already the content of pdf file (binary/ascii issue apart). Do you want to convert it to base64 for other purpose (multipart mail for example)?
The API (HTTP Request) activity returns a string not binary. I think I then need to encode this string as Base63 and convert to byte array which is what I have done.
I only want to convert to base64 because I think that is the only way to then convert it to byte. What do you mean by ‘resulting archive’?
Could you please write the string received into your file in binary mode? Given myText the text received and filePath the pat to your file with .pdf extension:
My.Computer.FileSystem.WriteAllBytes(filePath, (From c In myText).ToArray(), True)
then try to open the file.
You’ll notice the second argument to the method is an Array of Bytes.
MyText should be directly the Result from your HTTP request. It will be the code in InvokeCode that will write the file.
By “writing in binary mode” I mean writing Bytes, preserving raw data. Carriage returns and Line feeds are not meant to represent new lines of text in a pdf file.
When you write your text file (as text), you’re changing the raw data.
The result from the HTTP request will be in string format. That is always the output of HTTP request, if I try to parse the output from the HTTP request directly into a bite it throws an error. So you would need to convert it to binary first, that was the idea behind the conversion.
The Output is a String, there’s nothing you can change as you mentioned it but you can use the Download Ressource with a .pdf filename and see if it does the trick. If not, please share the Response Info.
ResponceDoc is the output of the HTTP request and I am parsing that into invoke code with MyText being the variable. This won’t work because I am trying to parse it as Byte while ResponceDoc is string. I also put a pdf file name into Resource Path