Visual Studioアプリケーションのキャンバスに画像を描画し、ボタンをクリックした後、その画像をPDFファイルに表示しようとしています。私はjavascriptとC#を使用しています。これまで、「A」というWebページを作成し、.aspxページでキャンバスとボタンを作成しましたが、.aspx.csページ(「<strong>」と表示されているページ)でこの画像を取得する方法がわかりません。ここに画像」)を使用して、PDFファイルに書き込むことができます。私のコードは現在、私のキャンバス画像をbase64に配置していると確信しています。どんな助けでも大歓迎です。ありがとう!
//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**));
}