Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PDF as blank page in HTML

My problem is, everything is fine opening PDFs using my browsers, until I uploaded a pdf with a form inside. Then, if I embed it, it returns a blank page. But the other pdfs with forms open normally. Please see my code below:

<object data="{{ asset($test->file_path) }}" type="application/pdf" width="100%" height="100%">
    <embed src="{{ asset($test->file_path) }}" type='application/pdf'>
    <center>
        <a href="{{ route('download.test', ['id' => $test->id]) }}" class="btn btn-primary">Please click here to view</a>
    </center>
</object>

Note: I've also tried to use <iframe> but still returns blank page.

Solution:

option1:

Renamed my file that has # sign. And everything should work fine.

option2:

Use urlencode if needed.

like image 530
Jie Avatar asked Jan 22 '18 06:01

Jie


People also ask

Why are my PDF pages blank?

If the fillable fields in a PDF show as blank after getting filled in, the PDF will need to be printed to a new PDF to resolve this issue. This is typically caused when the PDF is filled using something other than Acrobat (i.e., a web browser or other PDF editing software).

Can you display PDF in HTML?

HTML's object tag is the first way to embed PDF files. In the below example, the pdf file will be displayed on a web page, which is an object. In addition to embedding a pdf file into a webpage, the object tag can embed ActiveX, Flash, video, audio, and Java applets.

Why is the first page of my PDF blank?

This is due to a recent Chrome update that prevents the in browser view of the PDF. You can change Chrome's settings so the PDF downloads and opens in Acrobat Reader.

How do you put a PDF in HTML?

The easiest way to put PDF in an HTML document is using the <a> tag with its href attribute. You need to add the URL or the reference link of your PDF file to the element.


2 Answers

<a href="{{ route('download.test', ['id' => $test->id] ,['target'=>'_blank']) }}" class="btn btn-primary">Please click here to view</a>
like image 141
ganesh avhad Avatar answered Oct 23 '22 03:10

ganesh avhad


It's late, and I'm tired, so apologies if I misread the question.

I noticed that the PDF is hosted on a site that doesn't support HTTPS. It showed a blank page if it was embedded on a site using HTTPS, but worked fine when it was using HTTP.

I think you need to either move the PDF to a site that supports HTTPS or make the site hosting the PDF start using HTTPS.

like image 28
SigaVPN Avatar answered Oct 23 '22 04:10

SigaVPN