I am working on content oriented website and using I frames to display pdf.when I am opening that page in the mobile browser it starts automatically starts downloading the pdf,how could I display pdf file using iframe in browser instead of downloading.
Now i am thinking to convert pdf's into HTML and pass HTML file as source in frame.
Suggest me some other alternative if I'm wrong and if I'm right then suggested me some pdf to HTML convertors,which can convert in bulk as I have very large number of files.
**EDIT:**thanks,it worked but can how can i stop it from being download,i'm thinking of disabling right click,will it work
One thing you can do is to upload your PDF somewhere and just use its URL.
You can also use Google PDF viewer for this purpose.
For more information check this Recommended way to embed PDF in HTML?
There are many ways you can make this possible one of them would be use the following <embed> element with source link to your pdf file :
<embed src="http://example.com/yourfile.pdf" width="1000" height="500" type='application/pdf'>
Another one is you can use the javascript library also :
pdf.js
and one last i have in mind is you can use google docs api url to view the : docx,doc,xls,pdf,ppt or any other document file online by using the method below:
https://docs.google.com/viewer?url=http://example.com/yourfile.pdf
Related
I have a webpage and I want to embed an external webpage on another server but I don't want any frame bars, and was hoping to use Php or Javascript to do this. The website I'm building is build using php.
I've tried
<?php
$remote = fopen("http://www.myotherwepage.com/apage", "r");
fpassthru($remote);
?>
But won't load properly no images will load and the style won't load.
This is the page I'm trying to embed
http://brands.datahc.com/?languageCode=EN
and I have my own (includes)naviagtion above and (includes)footer underneath.And it will need to expand and reseize for the user.
Just add an iframe element, and then style it using CSS. You can manipulate its size using jQuery or vanilla JS.
This way, you don't need to worry about fixing any broken or relative links. For example, the following code will turn off the scrollbars for the iframe:
<iframe src="http://brands.datahc.com/?languageCode=EN" srcolling="no"></iframe>
You could in turn look to implement some of the following functionality > http://css-tricks.com/cross-domain-iframe-resizing/. This will also ensure that the iframe is resized according to its content.
The problem is that all the images on the website are embedded with relative paths.
When you embed the website example.com which refers to an image http://example.com/image.jpg, its sourcecode only reads src="image.jpg". When you then integrate the sourcecode of that website into example.org, the image will be searched on http://example.org/image.jpg where it doesn't exist.
As a solution you could
rewrite all relative links and image paths by using a HTML parser or
use the HTML <base> element in the <head> of your website and set it to the url of the page you are embedding. That way the users web browser will interprete all relative URLs as relative to the embedded page, not the url of your own page.
Does anyone know how I can save a page as pdf in php?
Example:
I have a page that is able to catch the users signature. Now I would like to create a button on the page that will convert the page into pdf so that the file can be saved to a folder.
Below you can see what the signature page looks like:
There are a number of PHP PDF API and tools which convert or wrap up html content including drawings, links and images etc.
A very good thread from StackOverflow :
Convert HTML to PDF using PHP
TCPDF can output PDF's from html: http://www.tcpdf.org/
If you need to use more advanced html you can use WKHTMLTOPDF: http://wkhtmltopdf.org/
i want to open PDF file in a iframe OR windows Extjs
and let user click to add labels
what scripts can i use ?
im coding with Extjs / php /mysql
i use fpdf/fpdfi libraries to write on a PDF file
any idea ? help please
thank
Simply pointing iframe to PDF file only works when user has allowed it's web browser to embed Adobe Reader (I'm not even sure that other PDF-readers support this at all). This might be the common configuration for IE users, but in other browsers and especially on other OS-es it's not as common.
Another option is to use a service that renders your PDF as web page. For example using google docs it's dead easy:
<iframe
src="http://docs.google.com/gview?url=http://yourdomain.com/file.pdf&embedded=true"
style="width:600px; height:500px;"></iframe>
Is there any way I can direct display PDF files in modal boxes?
I am using CodeIgniter PHP framework and jQuery as JavaScript framework.
UPDATE: I read on net that this is possible by loading it in iframe, and Adobe PDF will render it, but many seems to oppose, so is there any way I can convert those PDFs to images?
Short answer: No.
Longer answer: Usually, PDF documents are not rendered by the browser directly, but rather by some specialized PDF reader. As soon as the browser sees a content type of application/pdf, it passes the response along to the reader. Nothing you would do in your HTTP headers, HTML or JavaScript would make it across the gap between the browser and that other program, and the PDF format itself contains no switch to enable any kind of modal user interface.
Update: Rendering the PDF as an image would allow you to display the graphical content of the document in a more modal fashion. You still are not able to block the user from closing the browser, but you would be able to "lock down" anything else on your page while the image is displayed.
Related: How do I convert a PDF document to a preview image in PHP?
If you really want to, you can just embed it as a normal object. For example:
<object type="application/pdf" data="embeddedfile.pdf" width="500" height="650">
That's a bad idea. Always let the user set their browser to how they want to handle PDF files. So just create a link to the pdf. Modal windows aren't for that purpose anyway.
How should i create a preview of image to be uploaded before it is actually submitted using AJAX in PHP?
Without uploading the image, this is going to be impossible in JavaScript as far as I can see, because security limitations are going to prevent you from determining the selected file in the file upload, and embedding that file in an img tag (as it used to be possible five years ago.)
You will be more lucky with Flash-based uploaders. I have seen some that offer the kind of functionality you want.
Update: Here's one that offers a preview function. From what I can see, it base64 encodes the local image and serves it to the surrounding HTML page as a inline data <img> tag. This is great because it might integrate well into your site. It does not work with any version of Internet Explorer, though.
Here's a fully Flash based solution that does previews in all browsers.
you first have to upload the document to server. Than you can show like.
<img src="uploads/file1_12224.jpg" />
The "file" input type doesn't expose the local file location of the file to be uploaded. It does "appear" to because as a user you can see the location, but the web page never knows this value. Without the local file address, you can't show a preview of the image on the web page using plain HTML or JavaScript.