我正在尝试在 Visual Studio 应用程序的画布上绘制图像,然后在单击按钮后将该图像显示在 PDF 文件中。我正在使用 javascript 和 C#。到目前为止,我创建了一个名为“A”的网页,并在 .aspx 页面中创建了一个画布和按钮,但我不确定如何在 .aspx.cs 页面中获取此图像(其中显示“<strong> Image Here”),以便它可以写入 PDF 文件。我很确定我的代码目前将我的画布图像置于 base 64 中。非常感谢任何帮助。谢谢!
//A.aspx:
//Create canvas and save as base 64
<head>
<script type="text/javascript">
$(document).ready(function() {
$('#saveButton').click(saveDrawing);
});
</script>
</head>
<canvas id ="canvas1" class="pad" width="198" height="55"></canvas>
<input type="button" name="saveButton" id="saveButton" value="Save Drawing">
<script type="text/javascript">
function saveDrawing() {
var canvas = document.getElementById("canvas1");
var context = canvas.getContext("2d");
var imgData = canvas.toDataURL();
//window.open(imgData); //Not sure if I need this or not
}
//A.aspx.cs: Code Behind
public void Method(string A)
{
PdfStamper pdfStamper = new PdfStamper(
pdfReader,
new FileStream(newFile, FileMode.Create)
);
AcroFields pdfForm = pdfStamper.AcroFields;
//This is where I need to get the image from A.aspx
pdfForm.SetField("Picture is", (**Image Here**));
}