How to change pdf tab title in browser - php

My pdf file is open in browser tab. In the title of pdf tab instead of name it shows the url how can i changed it .I am using codeigniter framework and using Mpdf library for pdf.

Your PDF document should have Title metadata set. Afterwards, browser will use it for rendering tab title.
http://www.w3.org/TR/WCAG20-TECHS/PDF18.html

In Acrobat Pro, open the PDF and select File -> Properties -> Description and then edit the meta data title (and others if required) as you see fit.
We only saw the title being displayed like this in Firefox.

Put it in a div inside a page and change the page title like this:
<head>
<title>YOUR TAB TITLE</title>
</head>
and then:
<div>
<object data="test.pdf" type="application/pdf"
width="300" height="200">
alt : test.pdf
</object>
</div>
You can also set the object width and height to match the page.
Reference

For changing PDF tab title in browser, you need to update "title" in property.
If you have PDF editor you can do it easily. Else it is not editable.
You can use any of the tool online to edit the title.
I did it using below link.
https://www.sejda.com/edit-pdf-metadata

Try this. It's so simple.
$mpdf->SetTitle('My Title');

Related

Title a PDF page [FPDF]

I'm generating some PDF on my site (with FPDF library) and I can't manage to change the title displayed in the browser (not the one when downloading, but the one corresponding to the HTML)
<title></title>
Have you any idea ?
Yes you can set/change the title by:
$pdf->SetTitle('Title');
Reference: http://www.fpdf.org/es/doc/settitle.htm

Displaying PDF file in a div or iFrame

Is there any way i can load PDF file (its contents) in a div or iFrame?
I have a bunch of PDF files on a server and, ideally, i need to have a button 'Show file' on a page, clicking on which will load the contents of selected file in a div(iFrame).
You can also use google pdf view by using iframe on your page :
<iframe src="http://docs.google.com/gview?url=http://infolab.stanford.edu/pub/papers/google.pdf&embedded=true" style="width:600px; height:500px;" frameborder="0"></iframe>
Instead of this in above code :
http://infolab.stanford.edu/pub/papers/google.pdf
Use your own PDF file path.
You can view the demo here.
http://googlesystem.blogspot.in/2009/09/embeddable-google-document-viewer.html
It's just a suggestion. No downvotes please.
Google's gview is sometimes unresponsive and given 204 status. Here is the best free alternative.
https://stackoverflow.com/a/66548544/2078462

How to print the content of an OBJECT element when using the FILE->PRINT menu?

I have a PHP script which displays a PDF inside an object element. Adobe Reader plugins handle this fine and using the Adobe toolbar users can print the embedded PDF. However, some users insist on using the File menu (98% of users on Internet explorer 8) to print the HTML document. Utilizing this File->Print menu in IE, the HTML document is printed out without the contents (PDF) of the OBJECT element. (Print Preview) Using this method to print the document in Chrome or FF results in only the data currently shown in the Object viewport, to be printed. That is, a partial object and not the actual PDF.
I have searched and read a few related questions on StackOverflow, but nothing specific to this situation or case. Some of these 'solutions' use a Javascript method or function to print the content via a button or link. If I can't get my users to use the Adobe toolbar in the browser to print a PDF, I doubt they'll change their minds to use a button that says 'PRINT'.
Why does the File->Print method in IE result in a blank page? Is there a way to make the browser print the contents of an Object element when using the File->Print menu. No JS hacks, buttons, links to 'click here', iframes, or suggestion to 'display it inline' etc.
For reference, the code for this 'View PDF' is below (which, again, works fine to display the PDF content in the object element; no issues).
echo "
<html>
<head>
<title>View PDF</title>
</head>
<body scroll='no'>
<object data='getFile.php?f={$file_hash}' type='application/pdf' width='100%' height='100%' >
<h2>Error: No PDF plugin</h2>
<p>The browser does not have a PDF viewer installed. In order to view the PDF in the browser, please <a href='http://get.adobe.com/reader'>download Adobe Reader</a>. </p>
</object>
</body>
</html>";
As far as I know there is no solution for this issue. I have seen some developers "solving" the problem by generating a PDF file that automatically shows the print dialog when opened
Another option could be to show the PDF file in a new window that removes the toolbar and menus in order to avoid the visual ambiguity.
Window.open(url, "_blank", "location=0,menubar=0,toolbar=0");
I do not know if this one works, but you could try detecting the browser print event, then calling pdfDoc.printAll(); on your Acrobat Reader object.
Open just the PDF - without the HTML & object. Then File->Print will always work.
Of course it depends much more on the browser/reader configuration if the PDF is displayed in the browser or opened in a new Reader window

set title of image document to display in browsers

I have an applicaton written in PHP that retrieves files from mongoDB Grid collection, and allows a user to view/download them based on if they're an image or not.
It's all working fine, except that the title bar of the browser displays the name of the php file I'm running the script in, rather than the filename of the image that's displayed. for example:
myphpfile (JPEG 1024 X 768 pixels)
I'm not sure if it's possible, but I'd like to change it if it is. If I right-click and select save as I get the correct image name, as user header() I've set:
content-disposition: inline; filename="thefilename"
I've also tried setting name with the content-type with no success.
Thanks for any help.
The only possible way is not to open image directly in the browser's window, but a simple HTML code like this:
<html>
<head>
<title>
Put your title here
</title>
</head>
<body>
<img src='your_script_generating_images.php?parameters'>
</body>
</html>
But did you think about some fancy and nice solutions like http://highslide.com/ or http://fancybox.net/? All that you need is to set the links to your script generating images and to update the page title correspondingly (which is not even required as you can write information you want just above the image in popup).

tinyMCE media embed, with media plugin in PHP + MySql

i'm using tinyMCE and i can't find the answer for this in their forums.
I'm using the "media" plugin to embed flash. the html result in html preview is normal:
<p><iframe src="http://www.youtube.com/embed/lWRi7gDYjVY" frameborder="0" width="425" height="350"></iframe></p>
the result saved to the database is quite different though, using mysql_real_escape_string it saves:
<p><img data-mce-json="{'type':'iframe','video':{'sources':[]},'params':{'src':'http://www.youtube.com/embed/lWRi7gDYjVY','frameborder':'0'},'width':'425','height':'350'}" class="mceItemMedia mceItemIframe" src="http://localhost/assets/scripts/tiny_mce/themes/advanced/img/trans.gif" data-mce-src="assets/scripts/tiny_mce/themes/advanced/img/trans.gif" width="425" height="350"></p>
and that is what is rendered on my page's html, showing only a white space the size of the iframe...
I'm really stuck and i don't know what to do.
Thanks
/Update/
well, i found out the source of the problem: i am saving my contents through AJAX; i havenĀ“t found a way to get the HTML content out of the editor with javascript so i was hacking it with a jQuery selector:
$('div').find('iframe').contents().find('body').html()
so that way i get the "wrong html" and it only happened with youtube videos so far.
My question is: how can i obtain the editor's HTML so i can post it through AJAX?
Thank you once again.
To obtain the editor's HTML use the following
// this is "content" by default else it is the id of your
// html element you get the editor for (usually a textarea)
var editor_id = 'put_your_editor_id_here';
editor = tinymce.get(editor_id);
var content = editor.getContent();
You may have a closer look at the tinymce API.
This is because the media plugin strips the tags that are considered invalid.
Can you try to change the option Valid_elements in Init and assign to [].
Try it.
good luck

Categories