Js自动分页

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<jsp:include page="keywords.jsp"></jsp:include>
<link href="css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
<link href="css/font-awesome.css?v=4.4.0" rel="stylesheet">
<!-- Data Tables --><!-- js自动分页Css -->
<link href="css/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet">
<link href="css/animate.css" rel="stylesheet">
<link href="css/style.css?v=4.1.0" rel="stylesheet">
</head>
<body class="gray-bg">
	<div class="wrapper wrapper-content animated fadeInRight">
		<div class="row">
			<div class="col-sm-12">
				<div class="ibox float-e-margins">
					<div class="ibox-content">
						<!-- js自动分页样式 -->
						<table class="table table-striped table-bordered table-hover dataTables-example">
							<thead>
								<tr>
									<th style="text-align: center;width: 1%">ID</th>
									<th style="text-align: center;width: 20%">职业</th>
									<th style="text-align: center;width: 8%">操作</th>
								</tr>
							</thead>
							<tbody>
								<c:forEach items="${zhiyeList}" var="list">
									<tr>
										<td>${list.id}</td>
										<td>${list.zhiye}</td>
										<td style="text-align: center;">
											<a href="zhiyeEdit?zhiye.id=${list.id}"><button type="button" class="btn btn-primary btn-success">修改</button></a>
											<button οnclick="del('zhiyeDel?zhiye.id=${list.id}')" type="button" class="btn btn-primary btn-danger">删除</button>
										</td>
									</tr>
								</c:forEach>
							</tbody>
						</table>
					</div>
				</div>
			</div>
		</div>
	</div>
	<!-- 全局js -->
	<script src="js/jquery.min.js?v=2.1.4"></script>
	<script src="js/bootstrap.min.js?v=3.3.6"></script>
	<script src="js/plugins/jeditable/jquery.jeditable.js"></script>
	<!-- Data Tables -->
	<script src="js/plugins/dataTables/jquery.dataTables.js"></script>
	<script src="js/plugins/dataTables/dataTables.bootstrap.js"></script>
	<script type="text/javascript" src="js/form-advanced-demo.js"></script>
	<script type="text/javascript" src="js/plugins/datapicker/bootstrap-datepicker.js"></script>
	<script type="text/javascript" src="js/plugins/layer/laydate/laydate.js"></script>
	<!-- 自定义js -->
	<script src="js/content.js?v=1.0.0"></script>
	<script type="text/javascript" src="../layer/layer.js"></script>
	<!-- Page-Level Scripts -->
	<script type="text/javascript">
        $(document).ready(function(){
        	$(".dataTables-example").dataTable({
        	"bPaginate" : true, //是否显示(应用)分页器  
            "bInfo" : true, //是否显示页脚信息,DataTables插件左下角显示记录数  
            "sPaginationType" : "full_numbers", //详细分页组,可以支持直接跳转到某页  
            "bSort" : true, //是否启动各个字段的排序功能  
            "aaSorting" : [[0, "desc"]], //默认的排序方式,第2列,升序排列  
            "bFilter" : true, //是否启动过滤、搜索功能  
		});
		});
    </script>
</body>
</html>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
可以使用pdf-lib库来实现自动分页。首先需要读取原始的pdf文件,然后根据页面大小和内容长度计算出每一页的内容,并将其添加到新的pdf文件中。 以下是一个简单的示例代码: ```javascript const { PDFDocument, StandardFonts, rgb } = require('pdf-lib'); const fs = require('fs'); async function createPages(doc, text) { const { width, height } = doc.getPage(0).getSize(); const font = await doc.embedFont(StandardFonts.Helvetica); const fontSize = 12; const leading = fontSize * 1.5; const lines = text.split('\n'); const lineHeight = font.heightAtSize(fontSize) + leading; const pageHeight = height - 72; // 1 inch margin let cursor = 0; let page = doc.addPage(); for (let line of lines) { const y = pageHeight - cursor % pageHeight; const textHeight = font.heightAtSize(fontSize, line); if (y - textHeight < 0) { page = doc.addPage(); cursor = 0; } const textWidth = font.widthOfTextAtSize(line, fontSize); const x = (width - textWidth) / 2; page.drawText(line, { x, y, size: fontSize, font }); cursor += textHeight + leading; } } async function main() { const text = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed id risus nec lorem congue dignissim. Aliquam erat volutpat. Mauris consectetur pharetra mauris, ac lacinia ipsum ullamcorper vel. Suspendisse potenti.'; const existingPdfBytes = fs.readFileSync('input.pdf'); const doc = await PDFDocument.load(existingPdfBytes); await createPages(doc, text); const pdfBytes = await doc.save(); fs.writeFileSync('output.pdf', pdfBytes); } main(); ``` 这个示例代码可以将一个文本内容分页添加到一个现有的pdf文件中。其中,`createPages`函数根据文本内容计算出每一页的内容,并添加到pdf文件中。在这个函数中,我们首先获取pdf页面的大小,然后计算出每行文本的高度和页面的高度。接着,我们遍历文本的每一行,根据文本长度和页面大小计算出文本的坐标,并添加到页面中。如果当前页面已经添加了足够多的内容,我们就添加一个新的页面,并将光标位置归零。 注意,这个示例代码只是一个简单的示例,需要根据实际需求进行修改。特别是对于一些特殊的排版需求,可能需要更加复杂的分页算法。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

平凡的人类

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值