Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I need a library to read 2D barcode (datamatrix) from images on C# project (windows Forms).
I tried using some SDKs, but the SDKs I tried are not free.
Is there any free SDK for reading 2d Barcode from images?
There's an example available:
using DataMatrix.net; // Add ref to DataMatrix.net.dll
using System.Drawing; // Add ref to System.Drawing.
[...]
// ---------------------------------------------------------------
// Date 180310
// Purpose Get text from a DataMatrix image.
// Entry sFileName - Name of the barcode file (PNG, + path).
// Return The text.
// Comments See source, project DataMatrixTest, Program.cs.
// ---------------------------------------------------------------
private string DecodeText(string sFileName)
{
DmtxImageDecoder decoder = new DmtxImageDecoder();
System.Drawing.Bitmap oBitmap = new System.Drawing.Bitmap(sFileName);
List<string> oList = decoder.DecodeImage(oBitmap);
StringBuilder sb = new StringBuilder();
sb.Length = 0;
foreach (string s in oList)
{
sb.Append(s);
}
return sb.ToString();
}
You'll need DataMatrix.net!
Best free Datamatrix coder\decoder that i've used is libdmtx: http://www.libdmtx.org/ . It has c# wrapper, so feel free to use it. I can't write sample code right now, but if you won't be able to handle it yourself, i'll help you a bit later with that.
EDIT:
libdmtx comes with console utils - if you will be able to read your barcodes with console app, you surely will read it using code.
EDIT2:
Here's code samples: http://libdmtx.wikidot.com/libdmtx-net-wrapper
I wonder if you have pictures containing some other info, except the barcode. The thing is - i don't know any free\open source lib to handle finding barcode on a picture, containing any other data properly.
And here's the link to other datamatrix implementations: http://www.libdmtx.org/resources.php
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 months ago.
Improve this question
Can any one help me to extract only URL from image when doing images processing OCR.
I checked, all OCR dll are in paid version. Is there any free libraries.
I used IronOCR and problem solve. I created GetText Function which fetch URL from text when image converted to text.
IronTesseract IronOcr = new IronTesseract();
var Result = IronOcr.Read(Path.GetTempPath() + "image.png");
string _url = GetText(Result.Text);
private string GetText(string myString)
{
Match url = Regex.Match(myString, #"[-a-zA-Z0-9#:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()#%_\+.~#?&//=]*)");
return url.ToString();
}
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
I am looking to create a small windows app that will take a text file of hundreds, maybe thousands of lines of text and then randomize the text and print 5 lines seperated by a line break. I should be able to copy from the app and each time I hit the "generate" button it should delete the previous 5 text outputs.
Here's an example:
https://www.random.org/lists/
The difference is that this app randomizes and prints all lines. Could someone point me to some resources on how to do this exact thing?
Microsoft own c# developer portal has examples of how to read from a text file
How to: Read From a Text File (C# Programming Guide) which can get you started with loading the text.
Microsoft's own Developer Network also has information on random number generation and examples at Random Class
finally Microsoft's own ASP.Net ASP.NET Samples has load of examples and information about building web (or desktop) applications.
You should be able to find working examples and API information on all three of these locations, that will help you with your quest of development of C# applications.
//Initialize variables
static Random rnd;
static StreamReader reader;
static List<string> list;
//here we load the text file into a stream to read each line
using (reader = new StreamReader("TextFile1.txt"))
{
string line;
list = new List<string>();
rnd = new Random();
int index;
//read each line of the text file
while (!reader.EndOfStream)
{
line = reader.ReadLine();
//add the line to the list<string>
list.Add(line);
}
//pull 5 lines at random and print to the console window
for (int i = 0; i < 5; i++)
{
index = rnd.Next(0, list.Count);
Console.WriteLine(list[index]);
}
}
Console.ReadKey();
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 1 year ago.
Improve this question
I am trying to create a PDF generator using C#.NET but having some major difficulties. I have an xml files with the data and an xslt file for the template of the pdf. I tried many different libraries out there but can't seem to get this working properly. Can anyone suggest an example I can use that shows how to do this.
Any help would be much appreciated. Thanks
I found a solution using the excellent TransformXMLToHTML method by Marc Gravell to transform XML + XSLT to HTML.
The HTML can then be transformed to PDF.
This approach may have been slower than editing a PDF as binary. But it was stable and gave me full control over content quality.
Step 1 - transform XML + XSLT to HTML
I needed to add Nugets including:
https://www.nuget.org/packages/System.Xml.ReaderWriter/
using System.Xml;
using System.Xml.Xls;
using System.IO;
public static string TransformXMLToHTML(string inputXml, string xsltString)
{
XslCompiledTransform transform = new XslCompiledTransform();
using(XmlReader reader = XmlReader.Create(new StringReader(xsltString))) {
transform.Load(reader);
}
StringWriter results = new StringWriter();
using(XmlReader reader = XmlReader.Create(new StringReader(inputXml))) {
transform.Transform(reader, null, results);
}
return results.ToString();
}
Step 2 - Transform HTML to PDF
I tried:
https://github.com/rdvojmoc/DinkToPdf
IronPdf which was non free to deploy but the free trial was quite successful (https://ironpdf.com/examples/using-html-to-create-a-pdf/)
https://github.com/ArthurHub/HTML-Renderer
All worked and had their weaknesses and strengths.
[Lets not get into a debate about the best C# HTML to PDF converter.]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I find a algorithm writen by javascript,now i want to convert it to C#,
Any tool can do this?
Well, you could start with Javascript.Net to try your code within another application before rewriting/converting it. Whatever you do, don't rely on auto-generated code for an algorithm of any importance.
If memory serves, there was actually a flavor of JavaScript that ran on the .Net CLR. I don't think it ever caught on.
Using javascript.net or jscript with .net Reflector, will save you brain and keyboard, may be
There is a dialect of JavaScript called UnityScript that can be converted into C# using the UnityScript-to-C# converter.
I also wrote a tool called universal-transpiler can convert a small subset of JavaScript into C# and several other languages.
Input in JavaScript:
function add(a,b){
var g = [3,4,5];
return a+b+(g[0])+(g.length);
}
function divide(a,b){
return a/b;
}
Output in C# from universal-transpiler:
public static int add(int a,int b){
int[] g={3,4,5};
return a+b+(g[0])+(g.Length);
}
public static int divide(int a,int b){
return a/b;
}
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
How can I draw candle charts in C#? Does anybody has any examples with a nice interface?
I've used the MSChart and found it to be pretty good. It supports candlestick charts. I've used ZedGraph as well but found a few graphical anomalies showed up on my charts but they were otherwise good as well.
I use this for stock data but its in VB
With Chart1.ChartAreas("myarea")
.AxisY.Maximum = (Math.Ceiling((HighValue * 100)) / 100)
.AxisY.Minimum = (Math.Floor((LowValue * 100)) / 100)
.AxisY.LabelStyle.Format = "{0.00}"
End With
Dim s1 As New Series
With s1
.ChartArea = "myarea"
.ChartType = SeriesChartType.Candlestick
.XValueType = ChartValueType.String
.YValueType = ChartValueType.Single
.YValuesPerPoint = 4
.CustomProperties = "PriceDownColor=Red, PriceUpColor=Green"
End With
For i = Globals.GraphColumns - 1 To 0 Step -1
OutData = Data_Array.Item(i)
s1.Points.AddXY(OutData.thedate, OutData.high, OutData.low, OutData.close, OutData.open)
Next
Chart1.Series.Add(s1)
Me.Controls.Add(Chart1)
ZedGraph is a very easy-to-use LGPLed charting library that can handle candlestick charts.
If you need to save an image to disk, it can do that. If you need to display an interactive graph that supports zooming/panning, it can do that as well with the excellent ZedGraphControl control.
I'm using the .netCharting library for this and it's pretty good. It supports all sorts of charts - candle included. One thing to watch out for is that with the current version (5.3) you have to reverse the high and low price - a pretty ugly and obvious bug. It's a commercial product, but reasonably priced, so could be worth it, depending on your project.
Maybe ChartDirector can be a good solution
http://www.advsofteng.com/doc/cdcomdoc/candlestick.htm
Try xamChart Control Trial version from Infragistics.
Here is another sample at CodeProject