允许用户将网页导出为PDF以提高可读性的最好方法是什么?

编程入门 行业动态 更新时间:2024-10-27 08:39:14
本文介绍了允许用户将网页导出为PDF以提高可读性的最好方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个在线文档,显示从数据库值和应用程序值动态构建的报表。向用户显示哪种类型的报告是基于用户具有的各种安全权限。因此,通常管理员可以看到完整的报告,但客户服务顾问将只看到同一份报告的一部分。它做到这一点很好。

I have an online document which shows a report built dynamically from database values and application values. What type of report it shows to the user is based on various security permissions that a user has. So generally a Manager can see a full report, but a Customer Service adviser will only see part of that same report. It does this just fine.

但现在看到的在线相同的报告也需要PDF版本。我已经开始构建一个新的.CFM模板,应该处理渲染同一个文档的PDF版本。它本质上是一个重复的在线版本,但基本的CSS格式和改变方式的文档是结构化的(例如没有jquery选项卡)。它仍然有条件逻辑。

But now the same report that is seen 'online' also needs a PDF version. I have started to build a new .CFM template which should handle rendering a PDF version of the same document. Its essentially a duplicate of the online version but with basic CSS formatting and change to way the document is structured (e.g. no jquery tabs). It still has the conditional logic in it.

但我现在来到一个阶段,我认为可能很难处理同一文档的两个文件。我的意思是,如果在在线版本的变化,那么PDF版本的代码也必须改变。

But I have now come to a stage where I think it may be difficult to handle two files for the same document. What I mean is that if something changes in the 'online' version, then code in the PDF version also has to change.

这是唯一的办法或有什么更好的方法来处理从网页导出到PDF?

Is this the only way to go about this or is there any better method of tackling exporting to PDF from a webpage? I just feel I'm doing it wrong.

推荐答案

cfdocument标签允许您动态创建PDF文件。您可以允许用户以各种方式选择他们的输出格式。

The cfdocument tag allows you to dynamically create PDF files. You can allow users to choose their output formats in a variety of ways.

我最常使用的是在用户输入搜索参数的表单上包含一个选择控件。我的选择一般是HTML或Excel,但它是相同的一般想法。当处理表单提交时,我最后做显示的东西。它将类似于:

The one I use most often is to include a select control on the form where the user enters their search parameters. My choices are generally HTML or Excel, but it's the same general idea. When processing the form submission, I do the display stuff last. It will resemble this:

<cfif form.showas is 'html'> code for web page <cfelse> code for something else <cfif>

由于您的选择是HTML或PDF,cfsavecontent标记可能派上用场。

Since your choices are HTML or PDF, the cfsavecontent tag might come in handy.

如果没有从表单访问您的页面,可以使用cfsavecontent生成一个具有所有输出的会话变量。然后,在您的网页上,提供链接或按钮或允许用户呈现为PDF的东西。您所做的就是将会话变量与cfdocument标记和Bob的您的叔叔组合。

If your page is not accessed from a form, you could use cfsavecontent to generate a session variable with all the output. Then, on your web page, offer a link or button or something that allows the user to render as PDF. All you do is combine the session variable with the cfdocument tag and Bob's your uncle.

更多推荐

允许用户将网页导出为PDF以提高可读性的最好方法是什么?

本文发布于:2023-11-06 01:51:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1562417.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:可读性   网页   方法   用户   PDF

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!