Skip to content

Commit

Permalink
(#260) Docs: document the exception thrown
Browse files Browse the repository at this point in the history
  • Loading branch information
ForNeVeR committed Jan 26, 2023
1 parent 4a524f1 commit 9c05420
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ For a more detailed sample, check out the [example project][example]. It shows t
The following example demonstrates usage of `TexFormula` API to render the image into a PNG file using the `RenderToPng` extension method:

```csharp
using System;
using System.IO;
using WpfMath;

Expand All @@ -40,15 +41,24 @@ namespace ConsoleApplication2
const string latex = @"\frac{2+2}{2}";
const string fileName = @"T:\Temp\formula.png";

var parser = new TexFormulaParser();
var formula = parser.Parse(latex);
var pngBytes = formula.RenderToPng(20.0, 0.0, 0.0, "Arial");
File.WriteAllBytes(fileName, pngBytes);
try
{
var parser = new TexFormulaParser();
var formula = parser.Parse(latex);
var pngBytes = formula.RenderToPng(20.0, 0.0, 0.0, "Arial");
File.WriteAllBytes(fileName, pngBytes);
}
catch (TexException e)
{
Console.Error.WriteLine("Error when parsing formula: " + e.Message);
}
}
}
}
```

Note that `WpfMath.TexFormulaParser::Parse` may throw a `WpfMath.TexException` if it was unable to parse a formula.

If you need any additional control over the image format, consider using the extension methods from the `WpfTeXFormulaExtensions` class:

```csharp
Expand Down

0 comments on commit 9c05420

Please sign in to comment.