I have a C# WinForms application that parses a text file and converts it into an image. The application works fine for normal text files. The problem I am facing is with the whitespaces in the text.
The code is:-
string text = File.ReadAllText(file);
Image img = DrawText(text);
img.Save("c:\\LoRa Demo\\pic.jpg", ImageFormat.Jpeg);
I am using the Graphics.DrawString() in the DrawText() to convert the text into image.
When parsing the following text, the white spaces don't occupy the same width in the string buffer as in the text file.
Text File content:-
***************************
****** **********
****** **********
***************************
***************************
Debugging shows the following image in the string buffer:-
The output image is same as the one in the buffer:-
How to parse the text file properly and convert it to image as in the text file ?
I think you should use monospaced fonts.
See: A list of monospaced fonts
Related
I have one PDF document with image. That image contains text.
Now I want to read the text from the image using pdfbox.
I have tried the PDTTextStripper but it not working for image text.
Can you please give some idea about it.
PDDocument pDDocument = PDDocument.load(new java.io.File(fileName));
PDFTextStripper textStripper = new PDFTextStripper();
string text = textStripper.getText(pDDocument);
Console.WriteLine(text);
I want to read the text inside the image from the pdf using pdfbox c# .net.
I want to convert the complex word document (which includes both text and images) into RTF text preserving formatting information. Sample image of document content is as shown below
How I can read this information as RTF text so that I can perfectly preserve the formatting and image location information. I tried to read word file using RichTextbox's LoadFile function but it doesn't preserve the formatting & image location information.
Looking forward to receive some suggestions to maintain the formatting and image location information.
Thanks
You could simply save the document in the RTF format...
I'm trying to copy an equation from word into a richtextbox control in winform.
The copy and the paste are done normally.But the paste of the equation is done as an image not as an equation file.(I cannot decode the pasted element in order to get the unicode text from it).
Is there a way to conserve the original component type after the paste is done ?
Or convert the image file to equation and get the unicode text from it ?
Any help would be appreciated
I am trying to convert a Bit map image in my windows 8 app (C#), to a string or a regular jpeg.
I am doing thins because I am trying to print the image in some html.
The image is stored in variable itemImage.
When I try to print in in the HTML using the image tag it doesn't show up.
"<img src=" +itemImage + "/>"
When I print in in the html in shows up as Windows.UI.Xaml.Media.Imaging.BitmapImage
How do I show the Image in the html?
You need to write the image out as a separate file, and then point the <img href=""> tag at that file. Alternatively, set the href to a callback line which calls your program with arguments that cause the program to emit the image data.
OR, you can embed the image data directly in the HTML, but that is a very EVIL hack and you absolutely should not under any circumstances do this. I did not mention this option. :)
I have a richtextbox and by far, i have been successful in converting plain text into pdf using iTextsharp. Now, the situation is, when i copy some text from any source let's say a website and along text, it contains images. Now when i try to convert the content (text + images) into pdf, resulting pdf doesn't show images. I know that there would be some property to be set for the richtextbox or using itextsharp so to have images as well. I also know that we can insert images by giving path to that image but this is not what i want. I want to have plain text along with images while direct conversion from richtextbox to pdf. Forexample i have,![Im resulting pdf i want the same as in richtextbox][1]: http://i.stack.imgur.com/ts0ec.jpg
How can i have the same as in richtextbox? How can i specify orientation for text and image to be justified?