0

I am using Chrome's built-in PDF support to display PDF documents. But I am not able to customize or even remove the PDF's title.

HTML:

<iframe [src]="docURL" alt="article.title" frameborder="0"></iframe>

Chrome: enter image description here Edge: enter image description here The title in Chrome is not apt and I want to customize it. Tried using title in iframe but didn't work. Please note that Microsoft Edge do not show this title.

Inspecting in DevTools:

enter image description here

Used display:none in #title and the title disappeared. But again its not overwriting/working when written in style.css. But still couldn't figure how to customize the title.

PS: Changing metadata of the file doesn't seem a solution for me. The PDF's are uploaded by users in my app and changing the file's metadata requires editing the properties section of the file.

Any help is appreciated.

Swapnil Sourabh
  • 459
  • 4
  • 17
  • 1
    Does this answer your question? [Change PDF title in browser window](https://stackoverflow.com/questions/22136043/change-pdf-title-in-browser-window) – Manas Khandelwal Jan 11 '21 at 09:16
  • 1
    The link in accepted answer has expired. Also it's changing the metadata to get the results,but my pdf are uploaded by users. Btw thanks. – Swapnil Sourabh Jan 11 '21 at 09:20
  • 2
    _“But again its not overwriting/working when written in style.css”_ - as your screenshot show, this is inside a shadow DOM - you can not “reach inside” that from your page’s own stylesheet. – CBroe Jan 11 '21 at 09:35
  • 1
    Okay @CBroe. Maybe that's why I need a better alternate. – Swapnil Sourabh Jan 11 '21 at 09:41
  • 1
    What exactly is your app? Is it a web service (on a web server)? Or something else? – user202729 Jan 11 '21 at 12:09
  • Think it as an online Windows Explorer, uploaded docs are handled by web service and docs are saved on server. To change metadata, it requires editing the properties of pdf by right-click or change metadata at creation. Both of which are not feasible here. I aim to get a solution where we can simply overwrite the title or hide it through pure HTML or some web-based solutions. Moreover generalizing the fact, is it best to overwrite metadata of an uploaded file? What if some devs need to use metadata in some other place. If this remains unanswered, I'll find a way to edit metadata via nodejs. – Swapnil Sourabh Jan 11 '21 at 13:00
  • So it's a web service, right? (you know I won't be notified without a "@"...) -- anyway it should not be possible to modify an iframe like that, but there are two options (1) modify the PDF's metadata (it's a web service, should not be hard) (2) provide the library yourself and modify it inside (Chrome uses PDFium, Firefox uses pdf.js) -- this way it also works the same across browsers. – user202729 Jan 12 '21 at 01:25
  • There's [javascript - Is there an NPM Module for PDF metadata? - Stack Overflow](https://stackoverflow.com/questions/41369213/is-there-an-npm-module-for-pdf-metadata) apparently. – user202729 Jan 12 '21 at 01:27

0 Answers0