Congratulations - C# Corner Q4, 2022 MVPs Announced
Why Join
Become a member
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
C# Corner Home
Technologies
Monthly Leaders
ASK A QUESTION
Forum guidelines
dip s
1.9k
251
54.4k
How to Embed PDF data (Base 64) in angular 6 component
Sep 23 2020 7:15 AM
Hi,
In my application in angular 6, I am showing Data(Report) in new window as follows.
*** result contains Base64 data***
if
(result !=
null
) {
const
pdfWindow = window.open(
""
);
pdfWindow.document.write(
"<html<head><title>Pathology Report</title><style>body{margin: 0px;}iframe{border-width: 0px;}</style></head>"
);
pdfWindow.document.write(
"<body><embed width='100%' height='100%' src='data:application/pdf;base64, "
+
encodeURI(result) +
"#toolbar=0&navpanes=0&scrollbar=0'></embed></body></html>"
)
Now what I want to do is like, I want to embed this data(result) in my angular component in <iframe> or <embed> tag.
My html code is as follows
<
iframe
[src]="PathReportString"
>
</
iframe
>
and component.ts code is
this
.PathReportString = (
this
.sanitizer.bypassSecurityTrustResourceUrl(result) as any).changingThisBreaksApplicationSecurity;
But it shows error "unsafe value used in a resource URL context"
How to embed data to component. Also my data is base64.
What is going wrong? Any help would be appreciated. Thank you.
Reply
Answers (
2
)
Save Shopping Cart to Check Out Page
Detect whether a browser, a tab close event has been occured?