Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Created April 18, 2024 07:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/c241d8b23d6c2f8eb1259c5ddedc92ed to your computer and use it in GitHub Desktop.
Save aspose-com-gists/c241d8b23d6c2f8eb1259c5ddedc92ed to your computer and use it in GitHub Desktop.
Convert PDF to Base64
// load PDF with an instance of Document
var document = new Document("Document.pdf");
// Add an additional page (optional)
// or made any changes to the document
document.Pages.Add();
// create Memory Stream
var memoryStream = new MemoryStream();
document.Save(memoryStream);
// create ByteArray with PDF content
var byteArray = memoryStream.ToArray();
// Converts ByteAray to Base64
var Base64Result = Convert.ToBase64String(byteArray);
// Show Results
Console.WriteLine(Base64Result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment