ngx-extended-pdf-viewer 9.0.0-alpha.3 IT DOES NOT WORK filenameForDowload

1.1k views Asked by At

Good evening . if someone could give me a hand with this problem: I am trying to change the name of the file when downloading the pdf but I cannot I am using [filenameForDowload] as the documentation says but I am not able to solve it, I leave them as I have it encoded

angular.json

...
build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "www",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "tsconfig.app.json",
            "assets": [
              {
                "glob": "**/*",
                "input": "src/assets",
                "output": "assets"
              },
              {
                "glob": "**/*.svg",
                "input": "node_modules/ionicons/dist/ionicons/svg",
                "output": "./svg"
              },
              {
                "glob": "web.config",
                "input": "src/",
                "output": "/"
              },
              {
                "glob": "**/*",
                "input": "node_modules/ngx-extended-pdf-viewer/bleeding-edge/",
                "output": "/bleeding-edge/"
              },
              "src/manifest.webmanifest"
            ],
            "styles": [
              {
                "input": "src/theme/variables.scss"
              },
              {
                "input": "src/global.scss"
              }
            ],
            "scripts": []
          },

app.module.ts

    import {  NgxExtendedPdfViewerModule } from 'ngx-extended-pdf-viewer';
    ..
         imports: [
            ...
            NgxExtendedPdfViewerModule,
          ], 
...

my_componet.ts

import { NgxExtendedPdfViewerService } from 'ngx-extended-pdf-viewer';
import { pdfDefaultOptions } from 'ngx-extended-pdf-viewer';
...

constructor(
    private ngxExtendedPdfViewerService: NgxExtendedPdfViewerService
  ) { 
    pdfDefaultOptions.assetsFolder = 'bleeding-edge';
   }

my_html.html

...
<ngx-extended-pdf-viewer
                           [base64Src]="docBase64"
                           useBrowserLocale="true"
                           height="100vh"
                           [filenameForDownload]="filename"
  ></ngx-extended-pdf-viewer>

I do not know if it is a problem as I have it configured, but when I define a name it only returns the one that is by default document.pdf If someone could give me help with that, I would appreciate it

2

There are 2 answers

1
Rogger Aldair Paredes Tavara On

I was able to find where my problem was: I had to change my angular.json file ->

"input": "node_modules / ngx-extended-pdf-viewer / bleeding-edge /",
 "output": "/ bleeding-edge /" 
by 
"input": "node_modules / ngx-extended-pdf-viewer / assets /",
 "output": "/ assets /"

and in my_componet.ts change

pdfDefaultOptions.assetsFolder = 'bleeding-edge'; 
by 
pdfDefaultOptions.assetsFolder = 'assets';

And just now I was able to change the name of the document when downloading, it seems that something is not working well when you use bleeding-edge, or it is also very likely that I am doing something wrong, anyway I leave the way to solve it

0
Usama Attique On

I am using Angular 13.I did not find the solution from the documentation,So I tried it myself and it Worked .

Change This

<ngx-extended-pdf-viewer
                           [base64Src]="docBase64"
                           useBrowserLocale="true"
                           height="100vh"
                           [filenameForDownload]="filename">
</ngx-extended-pdf-viewer>

To This

<ngx-extended-pdf-viewer
                           [base64Src]="docBase64"
                           useBrowserLocale="true"
                           height="100vh"
                           filenameForDownload="fileName.pdf">
</ngx-extended-pdf-viewer>