0

How can I retrieve my image drawn in my canvas tag on my Index.cshtml page in my Home Controller?

I can currently get the from them but not the value of to insert it into a PDF later

My index.cshtml:

<form asp-action="Index">
    <table>
        <tr>
            <th>Date</th>
            <th>Société</th>
            <th>Nom / Prénom</th>
            <th>Signature (matin)</th>
            <th>Signature (après-midi)</th>
        </tr>
        <tr>
            <td><input asp-for="dateFormation" type="date" /></td>
            <td><input asp-for="societeForme" type="text" /></td>
            <td><input asp-for="nomPrenomForme" type="text" /></td>
            <td><canvas id="signatureCanvas" width="200" height="100"></canvas></td>
            <td><canvas id="signatureCanvas2" width="200" height="100"></canvas></td>
        </tr>
    </table>

    @*BOUTON ENVOYER*@
    <br />
    <div class="myforma">
        <button type="submit">Envoyer formulaire</button>
    </div>
    <br />
</form>

My HomeController.cs:

public async Task<IActionResult> Index([Bind("dateFormation, societeForme, nomPrenomForme")] FormulaireModel formulaireModel)
{
    var renderer = new HtmlToPdf();
    var pdfCreate = renderer.RenderHtmlAsPdf(formulaireModel.typeFormation + " " + formulaireModel.dureeFormation + " " + formulaireModel.animateurFormation + " " + formulaireModel.dateFormation.ToShortDateString() + " " + formulaireModel.societeForme + " " + formulaireModel.nomPrenomForme);

    pdfCreate.SaveAs("liste-presence.pdf");

    return View();
}
Deweey04
  • 1
  • 1
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Jan 06 '23 at 08:43
  • Do you want to catch image in canvas tag then use it in the backend? You can refer to this [issue](https://stackoverflow.com/questions/923885/capture-html-canvas-as-gif-jpg-png-pdf). – Xinran Shen Jan 06 '23 at 09:03
  • I can make a drawing in my canvas tag, and I would like to save this drawing in a pdf afterwards to simulate a signature. So I want to pass the value of the tag in my MVC controller to inject it in my PDF later – Deweey04 Jan 06 '23 at 11:05

0 Answers0