Thread: C++ Outputting into a PDF file

  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    7

    C++ Outputting into a PDF file

    Hi,
    I need to output the results from my program into a pdf file, but I'm not sure how. Are there any easy to use libraries to do this ? And could you post step by step on how to use the library ?

    For example, how would I get the exact same output that this test program prints, but into a pdf file format ?
    Thanks,

    Code:
    #include <iostream>
    #include <string>
    
    using namespace std;
    
    int main()
    {
    	int num = 1000;
    	string a = "Test word";
    	int number[] = { 1, 3, 4, 5, 6, };
    	string words[] = { word1, word2, word3 };
    
    	cout << "Sample formatting for output. " << endl;
    	cout << "\tTest indent/tab" << endl;
    	cout << "\tTest indent/tab" << endl;
    	cout << "\t\tTest indent/tab" << endl;
    	cout << "\t\tTest indent/tab" << endl;
    	cout << "\t\t\tTest indent/tab" << endl;
    	cout << "\t\t\tTest indent/tab" << endl;
    
    	cout << "Values in array number: "
    	for ( int i = 0; i < (sizeof(number) / sizeof(int) ); i++ )
    	{
    		 cout << number[i] << " ";
    	}
    
    	cout << "Words in array words: "
    	for ( int i = 0; i < (sizeof(words) / sizeof(string) ); i++ )
    	{
    		 cout << number[i] << " ";
    	}
    
    	return 0;
    }

  2. #2
    Registered User
    Join Date
    Jan 2010
    Posts
    30
    I think it's unlikely that there are libraries that can help you do it.
    What you could do is to output your results into a Latex file, usually with ".tex" extension. Latex like HTML, is a markup language. Although it takes quite some time to master it, simple formatting is easily done. Then you compile the Latex file into a PDF.
    If you are using windows, you can download such a compiler here:
    proTeXt - a TeX distribution for Windows

  3. #3
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by chameleons View Post
    Then you compile the Latex file into a PDF.
    You can do the same thing with groff, which produces postscript (.ps) files, and those can be converted with ps2pdf on linux (which ps2pdf works 100% extremely well, the two formats suit one another I guess).

    But there must be some libs around to do .pdf output by now, surely???
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336

  5. #5
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by tabstop View Post
    They blow chunks. There's nothing good for free.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Newbie homework help
    By fossage in forum C Programming
    Replies: 3
    Last Post: 04-30-2009, 04:27 PM
  2. Problems passing a file pointer to functions
    By smitchell in forum C Programming
    Replies: 4
    Last Post: 09-30-2008, 02:29 PM
  3. help with text input
    By Alphawaves in forum C Programming
    Replies: 8
    Last Post: 04-08-2007, 04:54 PM
  4. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 02:58 AM