I just want to ask if there is some kind of kind of program in which I provide a PDF file with full of questions and that program selects from them randomly to ask me like a exam?!

For example: I am a pilot and I got a question bank (all mcqs) in PDF file. Now I want to insert that file in the desired program and have it randomly give me questions.

  • 2
    Mohammed - the first problem is that not all pdfs that display as text actually have that same text in them as text, e.g.: Scanned documents often have no, or very badly OCRed, text - just pictures of the pages. Apr 13, 2015 at 5:17
  • 2
    Please post a sample PDF file, otherwise we can't tell whether it is possible or not.
    – Nicolas Raoul
    Apr 13, 2015 at 5:42
  • @SteveBarnes: If there is 1 question per page, then I guess OCR is not needed :-)
    – Nicolas Raoul
    Apr 13, 2015 at 5:43
  • @NicolasRaoul - in that case all that is needed is to randomly display one page - a rather different question. Apr 13, 2015 at 5:46
  • 1
    Which operating system? Free, or do you have a budget? The more information that you give, the better we can help you. May 13, 2015 at 13:11

1 Answer 1


Please take a look at this StackOverflow question: Extracting one page from pdf file using iText, it contains a small code snippet that "burst" a PDF:

public static void main(String[] args) throws DocumentException, IOException {
    PdfReader reader = new PdfReader("resources/Abdomen.pdf");
    int n = reader.getNumberOfPages();
    String path;
    PdfStamper stamper;
    for (int i = 1; i <= n; i++) {
        reader = new PdfReader("resources/abdomen.pdf");
        path = String.format("results/abdomen/p-%s.pdf", i);
        stamper = new PdfStamper(reader,new FileOutputStream(path));

"Bursting" means: to split a PDF with X pages into X PDFs with a single page. If you only need a single page, you don't need to loop over the different pages, you can just use the code inside the for-loop to select one page.

The syntax of the parameter of the selectPages() method is explained in the answer to this question: PDF Page re-ordering using itext.

All of this is done in Java using iText, but if you prefer C#, we also have iTextSharp. There is a free ebook The Best iText Questions on StackOverflow that contains an abundance of code samples in Java as well as in C#.

  • 2
    A great solution if this were programmers. Maybe not so good for S/W recs? May 13, 2015 at 13:09
  • @Mawg For a question as specific as this one, one should not expect a software solution that works "out-of-the-box" in spite of the fact that the amount of programming that is needed to meet the requirement may be limited. May 13, 2015 at 13:45
  • But has the OP indicated in any way that he is a programmer? If so, I would expect him to either take a stab at it and post to stackoverflow.com if he has problems, or post to programmers.stackexchange.com for general implementation advice. AFIK, this site is for recommending "out of the box" s/w, or for stating that there probably isn't any - not for telling people how to code. May 13, 2015 at 13:56
  • 1
    I'd say it's welcome because even if it doesn't help the OP directly, there may be other readers who use the source code and turn it into a ready-made tool. May 13, 2015 at 14:48
  • 3
    A valid point. Let's see what others think ... meta.softwarerecs.stackexchange.com/questions/1201/… May 13, 2015 at 14:51

Not the answer you're looking for? Browse other questions tagged or ask your own question.