0

I am using SharePoint 2019 on premise version. I have a large document library of PDF file. I want to open any of the file in a web part not in new browser tab. Is there any way I can accomplish this task ? Thank you in advance.

1 Answer 1

0

We can display PDF files inside the content editor web part. Here is how: add a Content Editor web part to the page and place the object tag as below in HTML Source of the content editor web part.

Using Object Tag to display pdf document in CEWP:

<object width="400" height="500" type="application/pdf"
data="http://sp10.Crescent.com//MCM/Documents/Pre-Reads.pdf?#zoom=75&scrollbar=1&toolbar=1&navpanes=1"
 id="pdf_content">

PDF viewer in SharePoint Content Editor Webpart

Output:

PDF Files inside Content Editor-Output

How can we display any pdf file dynamically from the document library?

We can make it dynamic this way - create a list view webpart to display the document library and below to this wp add a script editor web part, then a write a js code to read the query string parameter along with the pdf URL or read the selected item URL , and pass this URL dynamically to the above mentioned html data tag (mentioned in the answer). This way we can make it dynamic.

Reference:

Display PDF Files in Content Editor Web Part

In modern SharePoint online we can use the Embed web part to display the PDF.

For embed web part reference, you may refer to the below article:

How to embed a PDF in a modern SharePoint page

3
  • Thank you Habibur Rahman.But my situation is that I have a list of .PDF file not any specific one. I want to open any of them in the list. If you can help me out , will be thankful. Thank you again. Commented May 7, 2020 at 16:38
  • WC bro :-) for your question answer is updated
    – SP 2022
    Commented May 7, 2020 at 17:57
  • Hello Habibur Rahman, I am not a programmer. It's a rocket science to me. You mention to write a javascript for dynamically open a pdf. I have no clue. If you can help, I will be grateful . Thank you Commented May 7, 2020 at 19:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.