I would like to open a pdf in my html page. I am using following sample php code for this
<?
$a= base64_encode("test");
$url=' <object type="application/pdf" data="data:application/pdf;base64,'.$a.'" width="800" height="800">No Support </object>';
echo $url;
?>
When we are running this code, got error:
Failed to load PDF document
Am I missing anything this code?
visit this link
how to display base64 encoded pdf?
it's impossible to display a pdf with a base64 string.
Related
I want to download PDFs from a website https://www.mca.gov.in/content/mca/global/en/data-and-reports/reports/monthly-information-bulletin.html which does not show the link or .pdf extension in the href tag clearly. I have loacted the tag which has the link but i am unalbe to figure out the code
for link in soup.select("a[href$='.pdf']"):
#try printing all pdf urls from the page
print (link)
How can I download these PDFs by changing these codes? Please suggest different codes if any. Thank you
I tried using the # which is mentioned in the href tag in this code
for link in soup.select("a[href$='.pdf']"):
#try printing all pdf urls from the page
print (link)
But the PDFs were not downloaded
I'm using the newest version of dompdf I just downloaded from here.
It's simple to embed image files like png like this:
<img src="data:image/png;base64,HERE_COMES_THE_BASE64_ENCODE" style="width:500px;height:500px;">
But sometimes I have a file I want to embed that's in pdf format.
Is it possible to embed and pdf file.
I tried the following the methods that exist in HTML to embed pdf files but it doesn't work. There's no error message, the page stays blank.
<object data="data:application/pdf;base64,HERE_COMES_THE_BASE64_ENCODE" type="application/pdf" style="width:500px;height:500px;"></object>
<iframe src="data:application/pdf;base64,HERE_COMES_THE_BASE64_ENCODE" style="width:500px;height:500px;"></iframe>
<embed src="data:application/pdf;base64,HERE_COMES_THE_BASE64_ENCODE" type="application/pdf" style="width:500px;height:500px;">
Is there any possibility to embed a pdf file in dompdf?
Or, if that isn't possible: Is it possible to attach my pdf file, as a new page?
I have the following line of code to embed pdf in HTML
<embed ngf-thumbnail="factura.picFile" id="factura_prev_pdf" ng-show="factura.preimageext=='pdf'" class="view_complete_image" type='application/pdf'>
As you can see I'm using ngf-thumbnail to show the pdf.
Javascript attached to the id just get the extension, not important here.
ng-show say true if extension id pdf and the css class adapt the pdf to the container size.
The thing is that the pdf preview is adapted to the width and height but the page is not visualized entirely.
Any idea ?
I saw things like Zoom to fit: PDF Embedded in HTML
But it doesn't work to me since I'm not using
EDIT what I see now is that you can modify a pdf url like http.thingthing.pdf#view=fit to make page fit but my files are loaded from local so it creates a blob:url where I cannot put this view=fit.
It's possible to convert this blob url to a normal url with the pdf extension?
Finally I achieved the following:
<img ngf-thumbnail="factura.picFile" id="factura_prev_image" class="view_complete_image">
<embed ngf-thumbnail="factura.picFile" id="factura_prev_pdf" ng-show="factura.preimageext=='pdf'" class="view_complete_image" type='application/pdf'>
<img src="{{ factura.image.url }}" ng-show="factura.preimage && factura.preimageext=='jpg'" id="factura_image" class="view_complete_image">
<embed src="{{ factura.image.url }}#view=fit" ng-show="factura.preimage && factura.preimageext=='pdf'" class="view_complete_image" type='application/pdf'>
As you can see, in the first 2 lines I'm using ngf-thumbnail... This two fields contains local files so to visualize it we get a Blob Url, in this way I couldn't add the #view=fit that allows me to visualize the entire pdf page.
In the last 2 lines we get pdf's that are uploaded to a server so we get a normal url.
In this way I can add the #view=fit so the page fits.
Hope it helps to someone.
This answer is to know how to fit a pdf page, but I'm not answering to fit the page when we get a Blob Url.
I have a external link to pdf(http://du.ac.in/du/uploads/Admissions/Cut-off/2016/First/290620161st_Cut_Off_DU_1.pdf). I want to show this pdf on my webpage without uploading this file to my server. Basically i want a pdf view embeded code but with the downloadable link of pdf file.
I'm reporting part of an answer of another question, should work
I recommend checking out PDFObject which is a Javascript library to embed PDFs in HTML files. It handles browser compatibility pretty well and will most likely work on IE8.
In your HTML, you could set up a div to display the PDFs:
<div id="pdfRenderer"></div>
Then, you can have Javascript code to embed a PDF in that div:
var pdf = new PDFObject({
url: "http://du.ac.in/du/uploads/Admissions/Cut-off/2016/First/290620161st_Cut_Off_DU_1.pdf",
id: "pdfRendered",
pdfOpenParams: {
view: "FitH"
}
}).embed("pdfRenderer");
I need to convert a html page(with images, buttons and a lot of css) to PDF and I'm using yii.
I chose mPDF over HTML2PDF(no particular reason for that.) When I render a page for converting to PDF, the PDF doesn't load, but when I use renderPartial, the page loads(only the html part works here).
I want the page to be completely converted to PDF and I tried going through the mPDF documentation but I couldn't 'find' anything useful.
this is my code :
$mPDF1 = Yii::app()->ePdf->mpdf();
$mPDF1->WriteHTML(
$this->render('render_page',
array( ...),
true ));
//Output PDF file
$mPDF1->Output();
Please let me know if I have to provide more informations...