Hi guys i want create a program that can write to a pdf file and here is the code i used.
when i run the program, it compiles well, and runs but the pdf file that is created is not readable/corrupt. i am just wondering whether there is some library that am supposed to use ......... thanx

#include<iostream>
#include<fstream>

using namespace std;

int main(){

 ofstream myFile;

 myFile.open("sample.pdf");
 
 myFile << "This is a sample for writing to a pdf file";

 myFile.close();


return 0;
}

The thing with PDFs are that aren't just strait up text files, I don't know how you would go about coding them and I can't imagine that it's easy so the standard I/O stream (istream, ostream, etc) aren't going to work.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.