將 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#