如何将乳胶配方图像保存到 Asp.net 中的文件夹
How to save latex formula image to a folder in Asp.net
我在项目中使用乳胶来使用公式。这是我的代码
EqEditor.embed('editor', '');
var a = new EqTextArea('equation', 'testbox');
EqEditor.add(a, false);
<link rel="stylesheet" type="text/css" href="http://latex.codecogs.com/css/equation-embed.css" />
<script type="text/javascript" src="http://latex.codecogs.com/js/eq_config.js"></script>
<div id="editor"></div>
<br />
<br />
<textarea id="testbox" rows="3" cols="40"></textarea>
<br />
<br />
<img id="equation" />
现在我想要,在制作公式后当我点击提交按钮时,公式应该保存到我的项目中的一个文件夹中,名称如 formula.png
请帮助我,使用 javascript 或 c#
我找到了一个快速的解决方案。它使用 URL 并获取参数并生成图像。
例如如果我想保存 "A + B = C",那么您可以按照以下步骤以编程方式生成图像。
- 对该字符串进行编码,就像这样 -
var k = encodeURI("a + b = c");
。 k 的值将等于 a%20+%20b%20=%20c
.
- 在
url = "http://latex.codecogs.com/gif.latex?" + k
中使用 k
。所以这将等于 http://latex.codecogs.com/gif.latex?a%20+%20b%20=%20c
.
您可以使用以下代码将远程 URL 图像保存到服务器 -
using( System.Net.WebClient wc = new System.Net.WebClient())
{
wc.DownloadFile("http://latex.codecogs.com/gif.latex?a%20+%20b%20=%20c", @"D:\a.gif"); // replace a.gif with actual file path, that will saved in server.
}
我在项目中使用乳胶来使用公式。这是我的代码
EqEditor.embed('editor', '');
var a = new EqTextArea('equation', 'testbox');
EqEditor.add(a, false);
<link rel="stylesheet" type="text/css" href="http://latex.codecogs.com/css/equation-embed.css" />
<script type="text/javascript" src="http://latex.codecogs.com/js/eq_config.js"></script>
<div id="editor"></div>
<br />
<br />
<textarea id="testbox" rows="3" cols="40"></textarea>
<br />
<br />
<img id="equation" />
现在我想要,在制作公式后当我点击提交按钮时,公式应该保存到我的项目中的一个文件夹中,名称如 formula.png
请帮助我,使用 javascript 或 c#
我找到了一个快速的解决方案。它使用 URL 并获取参数并生成图像。
例如如果我想保存 "A + B = C",那么您可以按照以下步骤以编程方式生成图像。
- 对该字符串进行编码,就像这样 -
var k = encodeURI("a + b = c");
。 k 的值将等于a%20+%20b%20=%20c
. - 在
url = "http://latex.codecogs.com/gif.latex?" + k
中使用k
。所以这将等于http://latex.codecogs.com/gif.latex?a%20+%20b%20=%20c
. 您可以使用以下代码将远程 URL 图像保存到服务器 -
using( System.Net.WebClient wc = new System.Net.WebClient()) { wc.DownloadFile("http://latex.codecogs.com/gif.latex?a%20+%20b%20=%20c", @"D:\a.gif"); // replace a.gif with actual file path, that will saved in server. }