Inputting image data to PDF with iText

前端 未结 1 1064
再見小時候
再見小時候 2021-01-15 23:39

I have an ImageButton in my website that has a dynamic source well it basically looks like this: \"data:image/svg+xml;base64,....\"

So I am trying to insert an imag

相关标签:
1条回答
  • 2021-01-16 00:20

    I doubt anyone would google this but I figured it out so why not post an anwser.

    To implement data img types in to PDF remove the prefix part and then convert it back from base 64 in to array byte.

    string theSource = ((ImageButton)FindControl(fieldKey)).ImageUrl.Replace("data:image/png;base64,", "");
    iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(Convert.FromBase64String(theSource));
    
    0 讨论(0)
提交回复
热议问题