Skip to content

Instantly share code, notes, and snippets.

@rogeriotaques
Last active November 26, 2019 02:19
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 rogeriotaques/2c9001a56e8af430181cc09a24758e25 to your computer and use it in GitHub Desktop.
Save rogeriotaques/2c9001a56e8af430181cc09a24758e25 to your computer and use it in GitHub Desktop.
Converts a PDF file to base64 string.
getFileInfo(evt: any): void {
const reader: FileReader = new FileReader();
const files: Array<any> = evt.target.files || evt.dataTransfer.files;
reader.addEventListener(
'load',
() => {
this.form.file_path = reader.result;
},
false
);
if (files[0]) {
reader.readAsDataURL(files[0]);
}
} // getFileInfo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment