Bekzat Karayev

Greenhorn
+ Follow
since Mar 31, 2021
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Bekzat Karayev

Thanks for the replies, I will definitely check out the solutions that you suggested.

Right now, I am playing around with this PDFFlow library.  

I added it to my console app through NuGet Package Manager, it generates PDF files pretty easily, without much code.
I don't even need to use any System.IO methods. The library provides its own methods, that are named pretty straightforward, like this:



After running the console app, I get a legit PDF file inside Debug folder that can be opened in any viewer.
4 years ago
I have recently learned about File.WriteAllText and File.AppendAllText methods in C#. As I understand it, File.WriteAllText creates txt files and writes text to them without any problem.
But I tried this code in a console app:



It generates a "MyTest.pdf" file, but any PDF reader/viewer cannot open this file, as if it is corrupted. Seems like System.IO can only generate txt files, and assigns them whatever the extension that we specify.
So my question is how can I generate valid pdf files directly from C# code? If I need any exterior library for that purpose could you suggest any free ones?
4 years ago