将 PDF 转换为 Base64

This article was translated from English: Does it need improvement?
Translated
View the article in English
如何将 PDF 转换为 Base64?

PdfDocument 对象不包含直接获取 Base64 的属性,但你可以获取字节 [] 可用于获取 Base64。

var pdf = new PdfDocument("MyPDF.pdf");
var ByteArray = pdf.BinaryData;
var Base64Result= Convert.ToBase64String(ByteArray);
var pdf = new PdfDocument("MyPDF.pdf");
var ByteArray = pdf.BinaryData;
var Base64Result= Convert.ToBase64String(ByteArray);
Dim pdf = New PdfDocument("MyPDF.pdf")
Dim ByteArray = pdf.BinaryData
Dim Base64Result= Convert.ToBase64String(ByteArray)
VB   C#