4
I would like to know how to Gero a PDF file through a string with binary values, the values should actually turn a text (according to the ASCII table) and be written in PDF.
I tried to do it this way but I was unsuccessful:
string teste = "010001010101111001111111";
byte[] bytes = System.Text.Encoding.ASCII.GetBytes(teste);
File.WriteAllBytes(@"C:/teste.pdf", bytes);
What’s wrong with the code? The PDF is even created but nothing is written in it, the same doesn’t even open.
Hello, I did this way that you suggested however the PDF does not open, Adobe Reader says that there is no support for this type of file or it was damaged. What can it be?
– Raphael Teodoro
Insert this excerpt:
var text = Encoding.ASCII.GetString(bytes);
and post here the value oftext
, please.– igventurelli
The value returned was "E^ "
– Raphael Teodoro
That’s what was written in binary?
– igventurelli
Yes, actually it was random the number generated. But I did a test with my name "Raphael" in binary, and also did not generate the pdf with the content.
– Raphael Teodoro
In debug mode, when I hover over the "File" class, 3 properties appear: ERROR_ACCESS_DENIED = 5 ERROR_INVALID_PARAMETER = 87 Getfileexinfostandard = 0 Does this have anything to do with?
– Raphael Teodoro
I did a test saving as TXT and it was normal, the problem is to generate PDF
– Raphael Teodoro
Got it. Ever thought about using some framework to generate PDF? Take a look at iText
– igventurelli