Conversion from Pdf to text file

Hi,
I have this project for my college work but i'm not getting any single idea and with that I'm a newbie to C++. How do I ever Convert a .Pdf file to .txt file using C++.
Thanks in advance
Could you please tell me what exactly is happening in this conversion?
Not sure if it will work or not but its worth trying.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <iostream>
#include <fstream> //Needed anytime a program performs file input/output
#include <sstream>
using namespace std;


int _tmain(int argc, _TCHAR* argv[])
{
	ifstream infile; //Declaring an ifstream (input file stream) called infile. 
					   //This object allows me to bring in data from a file and call
	                   //the fstream libraries that open, close and otherwise manipulate input file

	ofstream outfile; //Declaring an ofstream (input file stream) called outfile. 
					   //This object allows me to print data to a file and call
	                   //the fstream libraries that open, close and otherwise manipulate output file
	                   //streams

	infile.open("yourfilename.pdf"); //This opens a file full of arbitrary data that is stored in a basic
	                         //text file, this file is saved in the same directory as my .cpp file, so
	                         //I did not have to specify a path

	outfile.open("yourfileOutput.txt"); //This opens or creates a file for output. if einsteinPicOutput.txt exists, it will create a new, empty
	                           //file and save over the old one. If it does not exist, it will create a new one.
	                           //outfile now has a file to output data to
	
	
	
	//A string variable named line that can hold a line of text being read in from the file
	string aLine;
	

		cout << aLine;
		
		//cout is the output stream that leads to the console (Console OUTput)
		//above a different output stream was created and a file was opened
		//for it to output to. outfile used in conjunction with the output stream operators
		// << will output data to the file data2.txt.
		outfile << aLine << endl;


	}
	system("pause");

	return 0;
}
Last edited on
The source is available at the link given. Read it.

The pdf file specification: (easily found via search engine)
http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/pdf/pdfs/PDF32000_2008.pdf

That code was compiling but the output i got was a blank text file. Why is this happening?
Last edited on
Topic archived. No new replies allowed.