Basics are: Another area of my program takes in strokes and then uses the recogniser to interpret those strokes into a recognise result. The result of this conversion is saved and is accessible. This is the string part of my question.

On another screen I have a panel which takes in strokes (using inkOverlay) for this area it's important that I save the strokes and not a recognition result (it's a "signature box")

I have a way to save the text into a text file.
I have a way to save the strokes of the signature box as a particular image file.

Does anyone have any ideas on how I can combine these two files (preferably without making two accessible copies of these separate file) so I have a file containing the string of recognised text and a signature image in the same file (preferably as a PDF but to start, lets say saved to a text file?)

Recommended Answers

All 4 Replies

You could use a BinaryWriter to put them both into the same file. I'd put some sort of header to indicate the length of the string and the length of the image part.

Momerath - let me try that. I'll post my solution and if it was successful or not!

Result!

byte[] bytes;
            //signature
            int value = inkOverlay.Ink.Strokes.Count;
            
            if (value > 0)
            {
                SaveFileDialog savedl = new SaveFileDialog();
                savedl.Filter = ".txt files (*.txt)|*.txt";

                if (savedl.ShowDialog() == DialogResult.OK)
                {
                    stream = savedl.OpenFile();
                    if (stream != null)
                    {
                        bytes = inkOverlay.Ink.Save();
                        String statement = richTextBox2.Text;
                        String time = label5.Text;
                        String text = statement + System.Environment.NewLine + time;

                        BinaryWriter binWriter = new BinaryWriter(stream);

                        binWriter.Write(text);
                        binWriter.Write(bytes);

                        binWriter.Close();
                    }

                }

The above code was learned from both
http://csharp.net-informations.com/file/csharp-binarywriter.htm
http://msdn.microsoft.com/en-us/library/6ka1wd3w.aspx

Because I want a file that can be opened I saved it as a .txt file, however the result of this file is partially correct...

held there my chicken
02/12/2010 13:23:39 ¬Ê\HE52  é¤âA3 ´ëãA«ªÓA
\|
}¨‚ü)øM0ÅWJU«,Ë–‘$»gEݶøHç‰1–ï{ÝYÍvùóÞ™> 2rËZ„9^*ví¶&d“]íi›€‚ü…ùjm/*e„Â5fÅ¢nK,2%”¶hÝ›šÅÌII²—q'‹›­[e–BL©µn‘1•©«k@

where the first part is the "statement" section, the second line is the timestamp and the rest is an ASCII representation of the strokes as shown in a .txt file.

Next task is to try and have the strokes saved as some sort of image within the text file so the strokes are represented as strokes and the string is represented as a string. I can do these two separately by saving the strokes as an image and the strings together as a text file.

I have an idea that I'll have to start looking into the inner workings of .doc or .pdf files?

I've managed to do this by saving the strokes as an image and the text as a text to a PDF document using iTextSharp.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.