Created
June 21, 2016 00:58
-
-
Save heejune/d5d7150371038cc3fc25cd869d84c538 to your computer and use it in GitHub Desktop.
Convert the PDF file into base64 string and pass it to the webbrowser control
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (locateText.Text.EndsWith("pdf", true, null) == true && | |
File.Exists(locateText.Text) == true) | |
{ | |
var buffer = File.ReadAllBytes(locateText.Text); | |
// Document.InvokeScript seems not understanding the Blob type | |
//object[] args = { fileBytes }; | |
//webBrowser1.Document.InvokeScript("PDFViewerApplication.open", args); | |
// so convert it to base64 and pass it | |
var asBase64 = Convert.ToBase64String(buffer); | |
webBrowser1.Document.InvokeScript("openPdfAsBase64", new[] { asBase64 }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment