Hi @Qamar, Mo ,
From your description, I suggest that you can use jqu ery toDataURL
to convert the canvas to image/png format first.
We can then use ajax
to send this image to a web method in code-behind.
Finally, we can save the image in the web method.
You can refer to the demo below.
179506-behind.txt
179905-front.txt
Edit
public static void UploadImage(string imageData)
{
byte[] data = Convert.FromBase64String(imageData);
Document pdfDoc = new Document();
var output = new FileStream(HttpContext.Current.Server.MapPath("2.pdf"), FileMode.Create);
PdfWriter writer = PdfWriter.GetInstance(pdfDoc, output);
pdfDoc.Open();
iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(data);
pdfDoc.Add(img);
pdfDoc.Close();
}
protected void Button1_Click1(object sender, EventArgs e)
{
Process.Start(Server.MapPath("2.pdf"));
}
Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.