Thread: Extract 1st page from file using C

  1. #1
    Registered User
    Join Date
    Jul 2008
    Posts
    8

    Extract 1st page from file using C

    Hi,
    I am trying to figure out how to extract the 1st page from a pdf file using C. Once I have extracted it, I am going to save it into a new file. Can someone help me figure out how to do this?


    Thanks.


    Saad

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Well. Have you looked at a PDF file in plain text? You could, I suppose, look for the page marks. You won't be able to just grab that data and have a valid PDF though, I don't think.

  3. #3
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    As tabstop indicates, it's not entirely trivial to read PDF. PDF is a binary and structured format, and it is compressed. Both of these mean that you need to write code to understand teh binary format, the structure and before you get there, you'd have to decompress the actual content into its uncompressed form.

    If you want to succeed in that [and not spend a lot of time], you probably want to use a PDF library of some sort. I have no idea which of the ones listed here on wikipedia are good and which aren't, and which would do the task you want to solve - I expect even with a library, it's not an ENTIRELY trivial task.

    Of course, PDF reader itself can save parts of a PDF document.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    http://www.gnu.org/software/ghostscr...ostscript.html
    Has source code, and can deal with PDF files.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

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. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 12:36 PM
  3. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 03:44 PM
  4. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  5. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM