Extract 1st page from file using C

This is a discussion on Extract 1st page from file using C within the C Programming forums, part of the General Programming Boards category; Hi, I am trying to figure out how to extract the 1st page from a pdf file using C. Once ...

  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,185
    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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,344
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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, 01:46 PM
  5. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21