数据URI散列参数(隐藏数据URI的PDF工具栏) [英] Data URI Hash Parameters (Hide PDF toolbar for data URI)

查看:234
本文介绍了数据URI散列参数(隐藏数据URI的PDF工具栏)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个PDF base64编码数据URI。

例如:

  return< object data =data:application / pdf; base64,JVBERi0xLjMKJf //// 8KOCAwIG9 ... VmCjI0MTU4OAolJUVPRgo =type =application / pdf>< / object> 

我可以将它嵌入到页面中,而不会出现任何问题。但是,默认情况下,浏览器在PDF中包含一个工具栏。





似乎禁用此工具栏的唯一方法是在网址的末尾添加一些散列参数。



例如。

 < object data =path / to / file.pdf#toolbar = 0& navpanes = 0& scrollbar = 0type =application / pdf >< /对象> 

如果通过相对路径或URL访问PDF,这可以正常工作,但我无法弄清楚使用数据URI进行工作的方式。



有没有办法在URI的末尾包含这些哈希参数?



还是有人知道某种方式来隐藏这个工具栏?



任何帮助,非常感谢。提前致谢。 :)

解决方案

我自己也在这里,并且不幸地看着$ / b>

https://developer.mozilla.org/ en-US / docs / Web / HTTP / data_URIs



声明(在常见问题中):


不支持查询字符串等
数据URI的数据部分是不透明的,所以尝试使用查询字符串(页面特定的参数,语法?参数 - 数据)与数据URI将只包含查询字符串在数据URI表示。


似乎表明这是不可能的。



如果您试图阻止打印PDF,并且可以访问生成它的代码(例如iText),则可以通过编程方式禁用使用类似于(加密doc)的代码的打印按钮

  stamper.setE ncryption(null,null,PdfWriter.HideWindowUI,PdfWriter.STRENGTH40BITS); 
stamper.setViewerPreferences(PdfWriter.HideToolbar);

但这并不妨碍文档能够被保存。 (请参阅:
http://developers.itextpdf.com/question/how-disable-save-button-and-hide-menu-bar-adobe-reader



能够通过嵌入(或对象)元素传递参数会很好,但哼哼。


I have a PDF base64 encode data URI.

eg:

return <object data="data:application/pdf;base64,JVBERi0xLjMKJf////8KOCAwIG9...VmCjI0MTU4OAolJUVPRgo=" type="application/pdf"></object>

I am able to embed it in the page without any problem. However, by default browsers include a toolbar in the PDF.

It seems like the only way to disable this toolbar is to include some hash parameters at the end of the url.

eg.

<object data="path/to/file.pdf#toolbar=0&navpanes=0&scrollbar=0" type="application/pdf"></object>

Which works fine if the PDF is accessed through a relative path or URL, but I cant figure out a way to make this work with a data URI.

Is there any way to include these hash parameters at the end of a URI?

Or does anyone know some way to hide this toolbar some other way?

Any help is greatly appreciated. Thanks in advance. :)

解决方案

I'm in the same position myself here, and, unfortunately looking at

https://developer.mozilla.org/en-US/docs/Web/HTTP/data_URIs

the statement (within "common problems"):

No support for query strings, etc. The data portion of a data URI is opaque, so an attempt to use a query string (page-specific parameters, with the syntax ?parameter-data) with a data URI will just include the query string in the data the URI represents.

seems to indicate that this is not possible.

If you are trying to prevent the printing of the PDF, and have access to the code that generates it (such as iText) you can programatically disable the print button using code similar to (encrypting the doc)

stamper.setEncryption(null,null, PdfWriter.HideWindowUI, PdfWriter.STRENGTH40BITS); 
stamper.setViewerPreferences(PdfWriter.HideToolbar);

however this will not prevent the document being able to be saved. (see : http://developers.itextpdf.com/question/how-disable-save-button-and-hide-menu-bar-adobe-reader)

It would be nice to be able to pass through has parameters to an embed(or object) element, but ho hum.

这篇关于数据URI散列参数(隐藏数据URI的PDF工具栏)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆