问题描述
我有一份PDF格式的文件,其格式为
您可以设置由与 setProperties
方法:
var doc = new jsPDF();
doc.setProperties({
title:这是我的标题
});
...
该标题将显示在Chrome的PDF查看器中。您可以在页面中测试它。
I've got a PDF file in the form of a Blob object (generated with jsPDF), that I want to display in an <iframe>
element.
I can do that easily this way:
iframe.src = URL.createObjectURL( blob )
The PDF is rendered correctly but I get an esoteric string in place of its name (see image below of Chrome's PDF viewer).
So I tried to convert the Blob to a File object in order to give it a human-readable name.
var file = new File( [blob], 'a_name.pdf', { type: 'application/pdf' } )
iframe.src = URL.createObjectURL( file )
It works with Firefox: the name is kept when saving the file from the header's PDF viewer.Unfortunately it is dropped in Chrome and replaced with a random file name before being loaded in the PDF viewer.
Do you know if it is possible to display the PDF File object in the <iframe>
with its file name?
You can set the title of the PDF generated by jsPDF with the setProperties
method:
var doc = new jsPDF();
doc.setProperties({
title: "This is my title"
});
...
That title will be displayed in the PDF viewer in Chrome. You can test it in the Live Demo page.
这篇关于如何在Chrome的PDF查看器中以其名称显示JavaScript File对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!