36 messaggi dal 18 aprile 2018
Buonasera,
ho fatto un pagina view che permette di mettere la firma tramite un canvas in un documento online.
il problema è che Itextsharp nel controller non becca l'immagine e mi ferma dando l'errore:

URI NON RICONOSCIUTO

Il codice che utilizzo nel controller è:

    [HttpPost]
    [ValidateInput(false)]
    public ActionResult Index(string TxtHtmlCode)
    {
StringReader sr = new StringReader("<html>"+ TxtHtmlCode + "</html>");

      Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);


// HTMLWorker htmlparser = new HTMLWorker(pdfDoc); --> questo me lo segnala come deprecato
      HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
      using (MemoryStream memoryStream = new MemoryStream())
      {
        PdfWriter writer = PdfWriter.GetInstance(pdfDoc, memoryStream);
        pdfDoc.Open();
        
        htmlparser.Parse(sr);
        pdfDoc.Close();

        byte[] bytes = memoryStream.ToArray();
        memoryStream.Close();

      Response.Clear();

      Response.ContentType = "application/pdf";

      Response.AddHeader("Content-Disposition", "attachment; filename=Invoice.pdf");



      Response.Buffer = true;

      Response.Cache.SetCacheability(HttpCacheability.NoCache);

      Response.BinaryWrite(bytes);

      Response.End();

      Response.Close();

      }

      return View();
    }



la stringa che mando "TxtHtmlCode" contiene il codice html di tutta la pagina compresa la firma che è di questo formato:

<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAu4AAACWCAYAAACB8w1PAAAOaklEQVR4nO3de5DdZX3H8YNAwk2Q+0WIoJuEcGbPnt/n8/39jofQeqRVrIKlY1dpgVbGaRQFnGm9UrV2RluxjlNTe2EQpFNBOgWdKqXtqK0XQKZYrDOFXmDQoRYqSQiQbLK5bLZ/+Bz6dIeQ7GbP/jY579fMM5vs+T3Pfvbkn2+e8/09v0YDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAACYgzVr1tyyZs2aaQaDwWAwGAwGYx/GLXXXtQe8NRTuDAaDwWAwGIx9HxTuAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAaDT+FxyDMCg8VZF7AAAAAElFTkSuQmCC">


un altra cosa che mi manca è salvare il file direttamente in una cartella sul server che se non presente la crea.

Grazie mille e complimenti per la professionalita con cui gestite questa community
Modificato da Mirko2018 il 10 luglio 2018 17.31 -
708 messaggi dal 11 febbraio 2013
Anche a me dava un errore del genere.
Mi sembra che l'img debba avere un percorso assoluto.

Non sono sicuro
36 messaggi dal 18 aprile 2018
Allora, alla fine ne sono venuto a capo utilizzando un'altra libreria ovvero SelectPdf, ha due versioni una free e una a pagamento, a me va benissiamo quella free che ha limitazioni tipo un documento non può avere più di 5 pagine. per il resto funziona egregiamente. Per il resto se avessi dovuto utilizzare per forza itextsharp come suggerivi tu, bisognava prima salvare l'immagine sul server e poi allegarla al documento PDf.
Modificato da Mirko2018 il 13 luglio 2018 10.11 -

Torna al forum | Feed RSS

ASPItalia.com non è responsabile per il contenuto dei messaggi presenti su questo servizio, non avendo nessun controllo sui messaggi postati nei propri forum, che rappresentano l'espressione del pensiero degli autori.