简体   繁体   English

将网页中选定的div集合导出为PDF或Word

[英]Export selected set of divs in web page to PDF or Word

Is the following possible? 以下可能吗? Given a web page with a set of divs with a special id or class, and in this div a title (h1?) and a piece of markup, present a selection list of the div titles witch checkboxes and a button to select all, export the selected divs to PDF or Word. 给定一个带有一组具有特殊ID或类的div的网页,并在该div中添加一个标题(h1?)和一个标记,请显示div标题的选择列表和多个复选框,并选择一个按钮进行全部导出将选定的div转换为PDF或Word。

Example markup: 标记示例:

:
<div class="selectable-and-exportable">
  <h1>Chapter One</h1>
  <p>Lorum ipsum. Lorum ipsum. Lorum ipsum.</p>
</div>
<div class="selectable-and-exportable">
  <h1>Chapter Two</h1>
  <p>Lorum ipsum. Lorum ipsum. Lorum ipsum.</p>
</div>
:

On click of export button present a lightbox or "in page" popup with: 点击导出按钮后,将显示一个灯箱或“页面内”弹出窗口,其中包含:

<Select all>

[X] Chapter One
[X] Chapter Two

<Export to Word> <Export to PDF>

EDIT: I think I better understand the question now. 编辑:我想我现在更好地理解了这个问题。 You're asking how to identify and present the fragments of the HTML document, not how to build the PDF/Word file. 您要问的是如何识别和呈现HTML文档的片段,而不是如何构建PDF / Word文件。

Assuming you're using jquery and the jquery-ui-dialog plugin, you might try something like this inside the dialog's open method: 假设您使用的是jquery和jquery-ui-dialog插件,则可以在对话框的open方法内尝试执行以下操作:

var jOptions; // this should be a reference to the element in the dialog body where you want to insert the various headings
jQuery('.selectable-and-exportable').find('h1').each(function(){
    var jThis = jQuery(this);
    jOptions.append('<input type="checkbox" name="sections" value="' + jThis.attr('id') + '" /> ' + jThis.text() + '<br />');

});

You'll need to write some code for the success method of the popup to actually capture the desired markup based on the set of checkboxes (you shouldn't stuff that markup inside the checkbox value attribute). 您需要为弹出式窗口的成功方法编写一些代码,以根据复选框的集合实际捕获所需的标记(您不应将标记填充在复选框的value属性中)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM