How to embed PDF from remote service into html page? Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of How to embed PDF from remote service into html page? without wasting too much if your time.

The question is published on by Tutorial Guruji team.

I’m developing a UI that interfaces with an existing back-end service. The UI needs to make a call to the back-end server for a PDF file that will either be displayed on the existing page or in a new tab.

I’ve tried all the options I’ve seen listed on SO:

<iframe src="http://localhost:3131/Reports.aspx?reportName=testReport&clientid=23" width="800px" height="100%"></iframe>

<embed type="application/pdf" src="//http://samelinkasabove" width="800px" height="100%">

<object type="application/pdf" data="http://myreportlink" width="800px" height="100%" />

<a href="http://localhost:32/Reports.aspx?reportName=testReport&clientid=23" target="_blank">View Report</a>

In every case, the pdf winds up as a download rather than being displayed in a browser window. Is there a native way to display a pdf or is javascript required to make this happen?

Answer

I found that the server was using CrystalReports to generate the PDF and “export” it. It used a function ExportToHttpResponse(...) and the third parameter in the method call was bool asAttachment.

That parameter was being set to true. I changed it to false and the response began being set to inline and the above display methods began working.

We are here to answer your question about How to embed PDF from remote service into html page? - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji