read a pdf file from url to to byte array

后端 未结 3 1061
故里飘歌
故里飘歌 2021-02-15 23:33

In an XML WebResponse I get a URL tag which has a link to a PDF file. Example of the URL value is: https://www.member-data.com/files/hb/c8955fc4d6160ec0fd87f4

相关标签:
3条回答
  • 2021-02-16 00:01

    You can use WebClient.DownloadData, which has a default return value of a byte array. e.g.

    byte[] bytes = myClient.DownloadData("https://www.member-data.com/files/hb/c8955fc4d6160ec0fd87f4879c6496d3.pdf");
    

    Also, this assumes that you want the actual file in a byte array, not the content (text) of the PDF. That's a whole other ball of wax.

    0 讨论(0)
  • 2021-02-16 00:07

    You can use WebClient.DownloadData().

    0 讨论(0)
  • 2021-02-16 00:13

    To convert a PDF to a byte array use the static method ReadAllBytes in the System.IO namespace

    0 讨论(0)
提交回复
热议问题