Angular how to display Blob with ngx-extended-pdf-viewer

Discussão em 'Angular' iniciado por santocielo99, Abril 23, 2025.

  1. santocielo99

    santocielo99 Guest

    I know there was already a question about this but the answer was "use something else" and I don't want to.

    in my app I need to display PDFs and I can't put them manually into the assets folder each time, I retrieve them from a server and get them as Blobs, now I read the documentation and I should be able to bind them to the src property but something isn't working, here's my code:

    import { pdfDefaultOptions } from 'ngx-extended-pdf-viewer';
    pdfToPreview?:Blob

    getDocPreview(){
    this.myService.getDocPreview().subscribe(data =>{
    this.pdfToPreview = data;
    })
    }


    and here's the html:

    <button data-bs-toggle="modal" data-bs-target="#provaPdfStaticModal (click)="getDocPreview()">
    viewer
    </button>

    <div class="modal fade" id="provaPdfStaticModal" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1"
    aria-labelledby="staticBackdropLabel2" aria-hidden="true">
    <div class="modal-dialog modal-dialog-mod modal-dialog-centered">
    <div class="modal-content">
    <div class="modal-header">
    <h5 class="modal-title" id="staticBackdropLabel2">PROVA PDF</h5>
    <button type="button" class="btn-close nosha" data-bs-dismiss="modal" aria-label="Close"></button>
    </div>
    <div class="modal-body">
    <div *ngIf="pdfToPreview != undefined">
    <ngx-extended-pdf-viewer
    [src]="pdfToPreview"
    [showPrintButton]="false"
    [showBookmarkButton]="false"
    [showOpenFileButton]="false"
    [showSidebarButton]="true"
    >
    </ngx-extended-pdf-viewer>
    </div>

    </div>
    <div class="modal-footer">
    FOOTER
    </div>
    </div>
    </div>
    </div>


    [​IMG]

    this is what I'm getting

    Am I dong something wrong?

    Continue reading...

Compartilhe esta Página