<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: munir abdullah</title>
    <description>The latest articles on DEV Community by munir abdullah (@munir_abdullah_8ecd8179a4).</description>
    <link>https://dev.to/munir_abdullah_8ecd8179a4</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1504910%2Fc2c94141-d452-4bb7-bae6-813f58c6e6f0.png</url>
      <title>DEV Community: munir abdullah</title>
      <link>https://dev.to/munir_abdullah_8ecd8179a4</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/munir_abdullah_8ecd8179a4"/>
    <language>en</language>
    <item>
      <title>I want to use ngx-doc-viewer read from input file</title>
      <dc:creator>munir abdullah</dc:creator>
      <pubDate>Wed, 20 Nov 2024 15:44:22 +0000</pubDate>
      <link>https://dev.to/munir_abdullah_8ecd8179a4/i-want-to-use-ngx-doc-viewer-read-from-input-file-1ehh</link>
      <guid>https://dev.to/munir_abdullah_8ecd8179a4/i-want-to-use-ngx-doc-viewer-read-from-input-file-1ehh</guid>
      <description>&lt;p&gt;&lt;code&gt;&amp;lt;input type="file" (change)="onFileSelected($event)" /&amp;gt;&lt;br&gt;
&amp;lt;ngx-doc-viewer [viewerUrl]="docUrl" [url]="docUrl" viewer="office" style="width:100%;height:50vh;"&amp;gt;&amp;lt;/ngx-doc-viewer&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;`import { Component } from '@angular/core';&lt;/p&gt;

&lt;p&gt;@Component({&lt;br&gt;
  selector: 'app-root',&lt;br&gt;
  templateUrl: './app.component.html',&lt;br&gt;
  styleUrls: ['./app.component.scss']&lt;br&gt;
})&lt;br&gt;
export class AppComponent {&lt;br&gt;
  docUrl: any;&lt;/p&gt;

&lt;p&gt;onFileSelected(event: Event): void {&lt;br&gt;
    const input = event.target as HTMLInputElement;&lt;br&gt;
    if (input.files &amp;amp;&amp;amp; input.files[0]) {&lt;br&gt;
      const file = input.files[0];&lt;br&gt;
      const reader = new FileReader();&lt;br&gt;
      reader.onload = (e: any) =&amp;gt; {&lt;br&gt;
        // const arrayBuffer = reader.result as ArrayBuffer;&lt;br&gt;
        // const base64String = this.arrayBufferToBase64(arrayBuffer);&lt;br&gt;
        this.docUrl = e.target.result;&lt;br&gt;
      };&lt;br&gt;
      reader.readAsArrayBuffer(file);&lt;br&gt;
    }&lt;br&gt;
  }&lt;/p&gt;

&lt;p&gt;arrayBufferToBase64(buffer: ArrayBuffer): string {&lt;br&gt;
    let binary = '';&lt;br&gt;
    const bytes = new Uint8Array(buffer);&lt;br&gt;
    const len = bytes.byteLength;&lt;br&gt;
    for (let i = 0; i &amp;lt; len; i++) {&lt;br&gt;
      binary += String.fromCharCode(bytes[i]);&lt;br&gt;
    }&lt;br&gt;
    return window.btoa(binary);&lt;br&gt;
  }&lt;/p&gt;

&lt;p&gt;}`&lt;/p&gt;

&lt;p&gt;this code note showing the word document for ex...&lt;/p&gt;

</description>
      <category>angular</category>
      <category>frontend</category>
    </item>
  </channel>
</rss>
