How to convert word search puzzles

Hello.
I’m in a position to convert some word search puzzles which are currently in the PDF format to ones that can be displayed on a monitor and then solved using a mouse (similar to those fancy java or flash ones). The whole thing is rather urgent.

A similar question was asked some 11 years back on this forum and is listed as ‘answered’ even though no solution is publicly given.

Any help will be greatly appreciated.

Regards,
Barb
Barbara-gAsked:
Who is Participating?
 
TheRealLokiSenior DeveloperCommented:
0
 
SteveBayCommented:
PDF has a very loose and wide definition as far as file formats go. We will need a good deal more information and even then this may prove to be quite difficult. If you can post an example of your PDF that may help in determining what’s involved.
0
 
Barbara-gAuthor Commented:
SteveBay, those puzzles are for school kids (3rd – 8th grade). They are finished and ready for print (please see attachment). Now, initiative is to convert them so that they could be displayed and solved using computer. And because I’m not versed in java or flash, the job have to be done in Delphi.

Regards,
Barb

Word-search-for-kids.pdf
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
SteveBayCommented:
I think the first step is to extract the text then you can manipulate it in all sorts of ways. You will need a tool to do this, there are several.  
I was able to extract the text in a way that made sense using QuickPDF http://www.quickpdflibrary.com/
0
 
Barbara-gAuthor Commented:
SteveBay, I apparently misspoke. I don’t need to convert pdf file, but to make a small app so that kids could solve the very same puzzle using computer (please see the attachment. Rename Project1.jpg to Project1.exe).

I sincerely apologize for my ignorance.

Regards,
Barb

Project1.jpg
0
 
SteveBayCommented:
Let me get this straight:

- You have PDFs that contain you puzzles.
- You want a program that reads your PDFs and uses the contents to create the same puzzle and allow a user to solve it within your program.
- So the program that you create would need to extract the text from the PDF and then lay it out so that it may be solved.
I’m pretty sure that means that the first step it to extract the text from the PDF.
0
 
Barbara-gAuthor Commented:
<q>- You have PDFs that contain you puzzles.
- You want a program that reads your PDFs and uses the contents to create the same puzzle and allow a user to solve it within your program.
- So the program that you create would need to extract the text from the PDF and then lay it out so that it may be solved.
I’m pretty sure that means that the first step it to extract the text from the PDF.</q>

WOW. That would be ideal, if you could do it. If you could, I would gladly compensate you for your effort. Please contact me at: gujics(at)shaw(dot)ca.

Regards,
Barb


0
 
SteveBayCommented:
I don't think that I am in a good position to write you an entire program but here is a simple example of extracting the text using QuickPDF http://www.quickpdflibrary.com/


unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation
Uses QuickPDF0717;
{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var qPDF: TQuickPDF;
begin
     qPDF := TQuickPDF.Create;
     Memo1.Lines.Text := qPDF.ExtractFilePageText('Word-search-for-kids.pdf','',1,0);
     qPDF.Free;
end;

end.

Open in new window

Results.JPG
0
 
TheRealLokiSenior DeveloperCommented:
You're asking for an expert to write the entire program for you.
If this is urgent, then a better forum would be "rentacoder" type sites.
I'm sure the program can be written easily, but since you say
"...because I’m not versed in java or flash, the job have to be done in Delphi"
you should at least write some of the delphi yourself
Otherwise, it appears any language would ultimately do....

Try asking a specific question for 1 aspect at a time to "assist" you in writing it yourself
e.g.
question 1: how do I get the data from PDF
question 2: how can I display the puzzle, that allows me to solve it programaticcaly and by user
question 3: how can I mark a word on this puzzle as "found"

that sort of thing.

you'll get a lot more experts chipping in that way.
a "big question" such as an entire application is too daunting, and many experts will just skip it since it would take too much of their valuable time.
(most of us have jobs and do these while our brain's are background processing)
0
 
Barbara-gAuthor Commented:
TheRealLoki,

Thank you for chipping in. I will have your advices on my mind. However:

<q>you should at least write some of the delphi yourself</q>

If you have downloaded attachment called ‘Project1.jpg’ which I included in exchange with SteveBay, renamed it to ‘Project1.exe’, and run it, you will see that I’m trying as hard as I could master and actually did ‘some of the delphi’. Also, I wouldn’t object if app is not only functional but looks appetizing, which is the dimension that kids will appreciate and one that only professionals could provide.

<q>You're asking for an expert to write the entire program for you.</q>

 That’s false. Please read my original question (even I do agree that question is sloppy and not specific enough). But…

<q>- You have PDFs that contain you puzzles.
- You want a program that reads your PDFs and uses the contents to create the same puzzle and allow a user to solve it within your program.
- So the program that you create would need to extract the text from the PDF and then lay it out so that it may be solved.
I’m pretty sure that means that the first step it to extract the text from the PDF.</q>…

…I could not help but to think that this is actually offer to do what SteveBay so skillfully describes (to make the whole thing). If so, I felt that I should compensate him for his effort.
 
I have a task to do and I’m asking for help (because I need it). That’s why I subscribed to ‘Experts-exchange’ – to be helped by professionals.

And I do accepting your critique that question is not clear enough. I’ll try to reformulate it:

What would be the optimal approach in adapting the word search puzzle which is ready for print to one which could be solved on computer?

One approach, as I see it, would be to use a text file and a string grid. Ideas on how to do it would be more than welcomed.  

Another would be to make a template containing of 100 labels where each label represents a letter in the grid, and using onmouseenter, onmouseexit,onmousedown, onmouseup and onmousemove.

Is there other ways of doing it? I’m open to any help that is offered.

Regards,
Barb

PS

As I mentioned I do accept your critique. If you offered some actual help instead, I would be even more appreciative.

B

       
0
 
TheRealLokiSenior DeveloperCommented:
lol
always willing to help. Just trying to make it easier for you to get more help ;-)
Personally, I'd suggest using a TPaintbox, and a bitmap
make the bitmap into tiles of 10x10 and use canvas.textout to draw the actual letters in the appropriate place.
Then you can detect the MouseDown, and MouseMove and draw the "line" as the child drags the line to the end letter.
When the MouseUp happens, you check an internal array (the 10x10 letters in an easier to search list) and see if it is 1 of the words.
if it is, you outline it, praise the child, and mark that word as done...

Comes down to how you want the child to choose the word.
  1.  Click on 1 letter at a time
  2.  Drag the mouse from start to end
  3.  other?
The graphic just makes it easier to work with the drawing of the outline imho
I'll do a sample when I'm at my development pc later
0
 
Barbara-gAuthor Commented:
TheRealLoki:

Speechless. Jaw dropping. Awestruck. Amazed. Captivated. Stunned. Enthralled. Astonished. Staggered…

Also ashamed at how little I know about programming. I will need some time to try to comprehend the code you did. Kudos to the depth of your knowledge.

If I dare to ask, would it be possible that the first letter in each word is marked somehow? Also for some reason, the word ‘Caraway’ is not working.

With highest regards,
Barb
0
 
Barbara-gAuthor Commented:
Simply incredible. Even in my wildest dreams I couldn't hope for solution of such quality.
0
 
TheRealLokiSenior DeveloperCommented:
"caraWay" does not work because the grid (which I just copied from the comment further up this page) has a V instead of a W
VINEFEECNV

marking the first letter (after correctly identified) can easily be done by a small change in the "DrawLines" routine
Since I included the code to track which "Direction" the word goes, you can actually enhance the "line" to be an elipse around the word (which is visually better)
It's a bit trickier though, so I did not do it straightaway.

Anyway, 3 other ways to highlight just the first letter are :-
  1. drawing a Larger/Coloured letter there instead
  2. Drawing a circle around it
  3. Changing the "background" colour

I'll put together a small sample when I have a bit more free time

Loki
0
 
TheRealLokiSenior DeveloperCommented:
Updated routine
set 1 or more of these 3 booleans to true to see a change :-
  HighlightFirstLetter_ChangeBackgroundColour
  HighlightFirstLetter_ChangeFont
  HighlightFirstLetter_DrawCircle

I'd still recommend working out a routine to draw a nice ellipse around the entire word, but that is more advanced.
It would involve merging the lines over the first and end letters and a bit of a restructure in the way the drawing happens

Have fun with this anyway


procedure TForm1.DrawLines;
var
  i, x, y: integer;
  s: string;
  HighlightFirstLetter_ChangeBackgroundColour: boolean;
  HighlightFirstLetter_ChangeFont: boolean;
  HighlightFirstLetter_DrawCircle: boolean;
begin
  HighlightFirstLetter_ChangeBackgroundColour := true;
  HighlightFirstLetter_ChangeFont             := false;
  HighlightFirstLetter_DrawCircle             := false;

// Highlight First Letters (this is separate because some words "share" letters and the line would be "erased" otherwise
  for i := 0 to pred(WordsToFind.Count) do
  begin
    if not assigned(WordsToFind.Objects[i]) then
      Raise Exception.Create('"WordsToFind" does not have a TWordMatch object in its'' object property');
    if TWordMatch(WordsToFind.Objects[i]).found then
    begin
      // Change Background colour of "cell"
      x := TWordMatch(WordsToFind.Objects[i]).startpoint.X*20 + 6; // used for redrawing "Letter" at end of this routine
      y := TWordMatch(WordsToFind.Objects[i]).startpoint.Y*20 + 2; // used for redrawing "Letter" at end of this routine
      CrosswordBitmap.Canvas.Font.Name := 'Courier New';   // default
      CrosswordBitmap.Canvas.Font.Size := 10;              // default
      CrosswordBitmap.Canvas.Font.Style := [fsBold];       // default
      CrosswordBitmap.Canvas.Font.Color := clBlue;         // default

      if HighlightFirstLetter_ChangeBackgroundColour then
        CrosswordBitmap.Canvas.Brush.Color := clLime;

      if HighlightFirstLetter_ChangeFont then
      begin
        CrosswordBitmap.Canvas.Font.Size := 12;
        CrosswordBitmap.Canvas.Font.Style := [fsBold];
        CrosswordBitmap.Canvas.Font.Color := clBlack;
//        X := X - 1; // because the font is bigger, we (may) need to centre it better
//        Y := Y - 1; // because the font is bigger, we (may) need to centre it better
      end;

// clear the cell
      CrosswordBitmap.Canvas.FillRect(rect(
        TWordMatch(WordsToFind.Objects[i]).startpoint.X*20 + 1, TWordMatch(WordsToFind.Objects[i]).startpoint.Y*20 + 1,
        TWordMatch(WordsToFind.Objects[i]).startpoint.X*20 + 20, TWordMatch(WordsToFind.Objects[i]).startpoint.Y*20 + 20));

// redraw the letter after our "highlighting"
      s := Crossword[TWordMatch(WordsToFind.Objects[i]).startpoint.Y];
      s := s[TWordMatch(WordsToFind.Objects[i]).startpoint.X+1];
      CrosswordBitmap.Canvas.TextOut(x, y, s);

      if HighlightFirstLetter_DrawCircle then
      begin
        CrosswordBitmap.Canvas.Pen.Color := clRed;
        CrosswordBitmap.Canvas.Brush.Style := bsClear;
        CrosswordBitmap.Canvas.Ellipse(rect(
          TWordMatch(WordsToFind.Objects[i]).startpoint.X*20 + 1, TWordMatch(WordsToFind.Objects[i]).startpoint.Y*20 + 1,
          TWordMatch(WordsToFind.Objects[i]).startpoint.X*20 + 20, TWordMatch(WordsToFind.Objects[i]).startpoint.Y*20 + 20));
      end;

    end;



  end;
// draw the lines
  for i := 0 to pred(WordsToFind.Count) do
  begin
    if not assigned(WordsToFind.Objects[i]) then
      Raise Exception.Create('"WordsToFind" does not have a TWordMatch object in its'' object property');
    if TWordMatch(WordsToFind.Objects[i]).found then
    begin
      CrosswordBitmap.Canvas.Pen.Color := clRed;
      CrosswordBitmap.Canvas.Pen.Width := 1;
      CrosswordBitmap.Canvas.MoveTo(TWordMatch(WordsToFind.Objects[i]).startpoint.X*20 + 9, TWordMatch(WordsToFind.Objects[i]).startpoint.Y*20 + 9 );
      CrosswordBitmap.Canvas.LineTo(TWordMatch(WordsToFind.Objects[i]).endpoint.X*20 + 9, TWordMatch(WordsToFind.Objects[i]).endpoint.Y*20 + 9 );
    end;
  end;
  Paintbox1.Canvas.Draw(0, 0, CrosswordBitmap);
end;

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.