Ascii to PDF

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?

NewBinary.xaml (5.5 KB)

input file
newbinary.txt (228.4 KB)


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.


Is this what you mean? It looks like I am getting the same result. Are you saying to still convert to base64 first?

NewBinary (2).xaml (5.6 KB)

I am using the same input file above

I don’t think base64 encoding is needed. I don’t have studio on this computer so I can’t read your workflow tonight.

I think you should save your requests content as pdf but write it in binary mode (not as text). That’s the purpose of the code I posted.

Can you download the ressource from your browser? If you can, please save it with .pdf extension and try to open it.

The string returned from the API is in ASCII Binary format

That solution above also returns a blank PDF.

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.

In the HTTP Request activity, have you check Download Ressource option and give a .pdf filename? Can you show the Response Info?

so have the output of the HTTP request MyText(bite) and then give ‘Download Ressource’ a .pdf file name?

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.

ok but if MyText is a string then you can’t parse that into invoke code because that needs to be parsed as a byte

If the file produced by DownloadResource option is as expected, you want need the invoke code: the HTTP Request will do the job by itself.

Actually, in the Invoke code the second argument given MyText as a String produce an Array of Byte so it will not prevent it to work.

I just pointed that was a way to produce bytes in answer to the following, sorry for confusion

MyText should remain a String

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