java itext后端生成pdf导出
public CustomApiResult<String> exportPdf(HttpServletRequest request, HttpServletResponse response) throws IOException {// 防止日志记录获取session异常request.getSession();// 设置编码格式response.setContentType("application/pdf;charset=UTF-8");response.setCharacterEncoding("utf-8");SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");String fileName = URLEncoder.encode("成品检验检验单" + dateFormat.format(new Date()), "UTF-8");response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".pdf");// 表头idString id = request.getParameter("id");// 分录idString taskEntryId = request.getParameter("entryId");
// 数据DynamicObject dynamicObject = getPdfData(Long.valueOf(id), Long.valueOf(taskEntryId));download(response, dynamicObject);return CustomApiResult.success("成功");}
画pdf
public void download(HttpServletResponse response, DynamicObject data) throws IOException {// 定义全局的字体静态变量Font headfont;Font content;// 最大宽度try {// 不同字体(这里定义为同一种字体:包含不同字号、不同style)BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);headfont = new Font(bfChinese, 14, Font.BOLD);content = new Font(bfChinese, 10, Font.NORMAL);BaseFont bf;Font font;//创建字体bf = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);//使用字体并给出颜色font = new Font(bf, 20, Font.BOLD, new Color(0, 0, 0));headfont = new Font(bf, 10, Font.BOLD, new Color(0, 0, 0));Document document = new Document(new RectangleReadOnly(842F, 595F));//设置页边距 60:左边距,60:右边距,72:上边距,72:下边距document.setMargins(60, 60, 72, 72);PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream());//添加页码writer.setPageEvent(new PdfPageUtil());//打开生成的pdf文件document.open();//设置内容Paragraph paragraph = new Paragraph("成品检验 检验单", font);paragraph.setAlignment(1);//引用字体document.add(paragraph);// --------任务分录---设置表格的列宽和列数float[] widths = {25f, 25f, 25f, 25f, 25f, 25f};PdfPTable table = new PdfPTable(widths);table.setSpacingBefore(20f);// 设置表格宽度为100%table.setWidthPercentage(100.0F);table.setHeaderRows(1);table.getDefaultCell().setHorizontalAlignment(1);PdfPCell cell = null;//第一行table.addCell(createCenteredCell("检验标准", 30, null, headfont));table.addCell(createCenteredCell(data.getString("eo45_standard_name"), 0, null, content));table.addCell(createCenteredCell("检验日期", 0, null, headfont));table.addCell(createCenteredCell(String.valueOf(data.getDate("eo45_check_date")), 0, null, content));table.addCell(createCenteredCell("检验人员", 0, null, headfont));table.addCell(createCenteredCell(data.getString("eo45_check_person"), 0, null, content));// 第二行table.addCell(createCenteredCell("生产厂家", 30, null, headfont));table.addCell(createCenteredCell(data.getString("eo45_suppliers"), 0, null, content));table.addCell(createCenteredCell("物料名称", 0, null, headfont));table.addCell(createCenteredCell(data.getString("eo45_material_names"), 0, null, content));table.addCell(createCenteredCell("物料规格", 0, null, headfont));table.addCell(createCenteredCell(data.getString("eo45_specifications"), 0, null, content));//第三行table.addCell(createCenteredCell("物料批次", 30, null, headfont));table.addCell(createCenteredCell(data.getString("eo45_material_batch"), 0, null, content));table.addCell(createCenteredCell("总数量", 0, null, headfont));table.addCell(createCenteredCell(data.getString("eo45_total"), 0, null, content));table.addCell(createCenteredCell("", 0, null, headfont));table.addCell(createCenteredCell("", 0, null, content));// --------检验详情---设置表格的列宽和列数float[] widths2 = {25f, 25f, 25f, 25f, 25f, 25f, 25f};PdfPTable table2 = new PdfPTable(widths2);table2.setSpacingBefore(20f);// 设置表格宽度为100%table2.setWidthPercentage(100.0F);table2.setHeaderRows(1);table2.getDefaultCell().setHorizontalAlignment(1);// 第一行table2.addCell(createCenteredCell("序号", 30, new Color(204, 204, 204), headfont));table2.addCell(createCenteredCell("检验项目", 0, new Color(204, 204, 204), headfont));table2.addCell(createCenteredCell("标准要求", 0, new Color(204, 204, 204), headfont));table2.addCell(createCenteredCell("检验方法及依据", 0, new Color(204, 204, 204), headfont));table2.addCell(createCenteredCell("抽样数量", 0, new Color(204, 204, 204), headfont));table2.addCell(createCenteredCell("实测结果", 0, new Color(204, 204, 204), headfont));table2.addCell(createCenteredCell("检验判定", 0, new Color(204, 204, 204), headfont));// 第二行开始循环数据DynamicObjectCollection item = data.getDynamicObjectCollection("eo45_zjy_task_item");Iterator var8 = item.iterator();int i = 0;while (var8.hasNext()) {i++;DynamicObject itemData = (DynamicObject) var8.next();PdfPCell cell1 = new PdfPCell(new Paragraph(String.valueOf(i), content));PdfPCell cell2 = new PdfPCell(new Paragraph(itemData.getString("eo45_project"), content));PdfPCell cell3 = new PdfPCell(new Paragraph(itemData.getString("eo45_standard_require"), content));PdfPCell cell4 = new PdfPCell(new Paragraph(itemData.getString("eo45_test_method"), content));PdfPCell cell5 = new PdfPCell(new Paragraph(itemData.getString("eo45_sample_qty"), content));JSONObject jsonObject = StringUtils.isNotEmpty(itemData.getString("eo45_actual_json"))? JSONObject.parseObject(itemData.getString("eo45_actual_json")) : new JSONObject();PdfPCell cell6 = new PdfPCell(new Paragraph("", content));String type = jsonObject.containsKey("type") ? jsonObject.getString("type") : "";// 根据json类型解析数据if ("number".equals(type)) {cell6 = new PdfPCell(new Paragraph(jsonObject.containsKey("value") ? jsonObject.getString("value") : "", content));} else if ("select".equals(type)) {JSONArray jsonArray = jsonObject.containsKey("option") ? JSONArray.parseArray(jsonObject.getString("option")) : null;if (jsonArray != null) {for (int j = 0; j < jsonArray.size(); j++) {JSONObject jsonObject1 = jsonArray.getJSONObject(j);if (jsonObject1.containsKey("selectStatus") && jsonObject1.getBoolean("selectStatus")) {cell6 = new PdfPCell(new Paragraph(jsonObject.getString("eo45_value_mapping"), content));}}}} else {cell6 = new PdfPCell(new Paragraph(jsonObject.getString("eo45_actual_json"), content));}PdfPCell cell7 = new PdfPCell(new Paragraph(itemData.getString("eo45_item_decide"), content));//单元格对齐方式cell1.setHorizontalAlignment(Element.ALIGN_CENTER);cell1.setVerticalAlignment(Element.ALIGN_MIDDLE);cell1.setFixedHeight(20);//单元格垂直对齐方式cell2.setHorizontalAlignment(Element.ALIGN_CENTER);cell2.setVerticalAlignment(Element.ALIGN_MIDDLE);cell3.setHorizontalAlignment(Element.ALIGN_CENTER);cell3.setVerticalAlignment(Element.ALIGN_MIDDLE);cell4.setHorizontalAlignment(Element.ALIGN_CENTER);cell4.setVerticalAlignment(Element.ALIGN_MIDDLE);cell5.setHorizontalAlignment(Element.ALIGN_CENTER);cell5.setVerticalAlignment(Element.ALIGN_MIDDLE);cell6.setHorizontalAlignment(Element.ALIGN_CENTER);cell6.setVerticalAlignment(Element.ALIGN_MIDDLE);cell7.setHorizontalAlignment(Element.ALIGN_CENTER);cell7.setVerticalAlignment(Element.ALIGN_MIDDLE);table2.addCell(cell1);table2.addCell(cell2);table2.addCell(cell3);table2.addCell(cell4);table2.addCell(cell5);table2.addCell(cell6);table2.addCell(cell7);}// ------综合判定----设置表格的列宽和列数// 设置表格的列宽和列数float[] widths3 = {25f, 75f};PdfPTable table3 = new PdfPTable(widths3);table3.setSpacingBefore(20f);// 设置表格宽度为100%table3.setWidthPercentage(100.0F);table3.setHeaderRows(1);table3.getDefaultCell().setHorizontalAlignment(1);cell = new PdfPCell(new Paragraph("综合判定", headfont));cell.setVerticalAlignment(Element.ALIGN_MIDDLE);cell.setHorizontalAlignment(Element.ALIGN_CENTER);cell.setFixedHeight(20);table3.addCell(cell);cell = new PdfPCell(new Paragraph(data.getString("eo45_decide"), content));cell.setVerticalAlignment(Element.ALIGN_MIDDLE);cell.setHorizontalAlignment(Element.ALIGN_CENTER);table3.addCell(cell);for (int j = 0; j < 1; j++) {PdfPCell cell1 = new PdfPCell(new Paragraph("备注", headfont));String contentResult = "";// 富文本处理if (StringUtils.isNotBlank(data.getString("eo45_decide_result"))) {org.jsoup.nodes.Document documentResult = Jsoup.parse(data.getString("eo45_decide_result"));contentResult = documentResult.text();}PdfPCell cell2 = new PdfPCell(new Paragraph(contentResult, content));//设置居中cell1.setHorizontalAlignment(Element.ALIGN_CENTER);cell1.setVerticalAlignment(Element.ALIGN_MIDDLE);cell1.setFixedHeight(20);cell2.setHorizontalAlignment(Element.ALIGN_CENTER);cell2.setVerticalAlignment(Element.ALIGN_MIDDLE);table3.addCell(cell1);table3.addCell(cell2);}document.add(table);document.add(table2);document.add(table3);//关闭文档document.close();} catch (DocumentException e) {log.error("导出pdf失败DocumentException:{}", e);} catch (Exception e) {log.error("导出pdf失败Exception:{}", e);}}private PdfPCell createCenteredCell(String value, float fixedHeight, Color color, Font font) {PdfPCell cell = new PdfPCell(new Paragraph(value, font));cell.setHorizontalAlignment(Element.ALIGN_CENTER);cell.setVerticalAlignment(Element.ALIGN_MIDDLE);// 设置背景色if (color != null) {cell.setBackgroundColor(color);}// 设置单元格高度if (fixedHeight != 0) {cell.setFixedHeight(fixedHeight);}return cell;}
工具类
import com.lowagie.text.*;
import com.lowagie.text.pdf.*;import java.io.IOException;/*** @Author xx* @Date 2023/12/15 10:05* @Description: 导出pdf添加页数* @Version 1.0*/
public class PdfPageUtil extends PdfPageEventHelper {/*** 页眉*///public String header = "itext测试页眉";/*** 文档字体大小,页脚页眉最好和文本大小一致*/public int presentFontSize = 9;/*** 文档页面大小,最好前面传入,否则默认为A4纸张*/public Rectangle pageSize = PageSize.A4;// 模板public PdfTemplate total;// 基础字体对象public BaseFont bf = null;// 利用基础字体生成的字体对象,一般用于生成中文文字public Font fontDetail = null;/**** 无参构造方法.**/public PdfPageUtil() {}/**** 构造方法.** @param** @param presentFontSize* 数据体字体大小* @param pageSize* 页面文档大小,A4,A5,A6横转翻转等Rectangle对象*/public PdfPageUtil( int presentFontSize, Rectangle pageSize) {this.presentFontSize = presentFontSize;this.pageSize = pageSize;}public void setPresentFontSize(int presentFontSize) {this.presentFontSize = presentFontSize;}/**** 文档打开时创建模板*/@Overridepublic void onOpenDocument(PdfWriter writer, Document document) {// 共 页 的矩形的长宽高total = writer.getDirectContent().createTemplate(50, 50);}/****关闭每页的时候,写入页眉,写入'第几页共'这几个字。*/@Overridepublic void onEndPage(PdfWriter writer, Document document) {this.addPage(writer, document);}//加分页public void addPage(PdfWriter writer, Document document){//设置分页页眉页脚字体try {if (bf == null) {bf = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", false);}if (fontDetail == null) {fontDetail = new Font(bf, presentFontSize, Font.NORMAL);// 数据体字体}} catch (DocumentException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();}// 1.写入页眉
// ColumnText.showTextAligned(writer.getDirectContent(),
// Element.ALIGN_LEFT, new Phrase(header, fontDetail),
// document.left(), document.top() + 20, 0);// 2.写入前半部分的 第 X页/共int pageS = writer.getPageNumber();//String foot1 = "第 " + pageS + " 页 /共";String foot1 = pageS +"/";Phrase footer = new Phrase(foot1, fontDetail);// 3.计算前半部分的foot1的长度,后面好定位最后一部分的'Y页'这俩字的x轴坐标,字体长度也要计算进去 = lenfloat len = bf.getWidthPoint(foot1, presentFontSize);// 4.拿到当前的PdfContentBytePdfContentByte cb = writer.getDirectContent();// 5.写入页脚1,x轴就是(右margin+左margin + right() -left()- len)/2.0FColumnText.showTextAligned(cb,Element.ALIGN_CENTER,footer,(document.rightMargin() + document.right()+ document.leftMargin() - document.left() - len) / 2.0F ,document.bottom() - 10, 0);cb.addTemplate(total, (document.rightMargin() + document.right()+ document.leftMargin() - document.left()) / 2.0F ,document.bottom() - 10); // 调节模版显示的位置}// //加水印
// public void addWatermark(PdfWriter writer){
// // 水印图片
// Image image;
// try {
// image = Image.getInstance("./web/images/001.jpg");
// PdfContentByte content = writer.getDirectContentUnder();
// content.beginText();
// // 开始写入水印
// for(int k=0;k<5;k++){
// for (int j = 0; j <4; j++) {
// image.setAbsolutePosition(150*j,170*k);
// content.addImage(image);
// }
// }
// content.endText();
// } catch (IOException | DocumentException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// }/**** 关闭文档时,替换模板,完成整个页眉页脚组件*/@Overridepublic void onCloseDocument(PdfWriter writer, Document document) {// 关闭文档的时候,将模板替换成实际的 Y 值total.beginText();// 生成的模版的字体、颜色total.setFontAndSize(bf, presentFontSize);//页脚内容拼接 如 第1页/共2页//String foot2 = " " + (writer.getPageNumber()) + " 页";//页脚内容拼接 如 第1页/共2页String foot2 = String.valueOf(writer.getPageNumber() - 1);// 模版显示的内容total.showText(foot2);total.endText();total.closePath();}
}

相关文章:
java itext后端生成pdf导出
public CustomApiResult<String> exportPdf(HttpServletRequest request, HttpServletResponse response) throws IOException {// 防止日志记录获取session异常request.getSession();// 设置编码格式response.setContentType("application/pdf;charsetUTF-8")…...
信号-3-信号处理
main 信号捕捉的操作 sigaction struct sigaction OS不允许信号处理方法进行嵌套:某一个信号正在被处理时,OS会自动block改信号,之后会自动恢复 同理,sigaction.sa_mask 为捕捉指定信号后临时屏蔽的表 pending什么时候清零&…...
38配置管理工具(如Ansible、Puppet、Chef)
每天五分钟学Linux | 第三十八课:配置管理工具(如Ansible、Puppet、Chef) 大家好!欢迎再次来到我们的“每天五分钟学Linux”系列教程。在前面的课程中,我们学习了如何安装和配置邮件服务器。今天,我们将探…...
网络技术-定义配置ACL规则的语法和命令
定义ACL(访问控制列表)规则时,具体命令会根据所使用的设备和操作系统而有所不同。以下是一些常见的设备和操作系统中定义ACL规则的命令示例: 一:思科(Cisco)路由器/交换机 在思科设备中&#…...
动态规划一>子数组系列
题目: 2.解析: 代码: public int maxSubArray(int[] nums) {int n nums.length;int[] dp new int[n 1];int ret Integer.MIN_VALUE;for(int i 1; i < n; i){dp[i] Math.max(nums[i - 1], dp[i - 1] nums[i - 1]);ret Math.max(…...
一觉睡醒,全世界计算机水平下降100倍,而我却精通C语言——scanf函数
大家好啊,我是小象٩(๑ω๑)۶ 我的博客:Xiao Fei Xiangζั͡ޓއއ 很高兴见到大家,希望能够和大家一起交流学习,共同进步。* 这一节我们主要来学习scanf的基本用法,了解scanf返回值,懂得scanf占位符和…...
Altium Designer使用技巧(五)
一、敷铜(快捷键T-G-A) 1、工具栏点“设计”—>“规则”。 可以修改覆铜连线的宽度,也可以选择“直接连接”使得铜和网络节点完全相连。 这里方式有三种,可根据需要各个人习惯去设置。 2、敷铜与线全链接 (1)少量的话可右键“…...
Docker 的安装与使用
Docker 的安装 Docker 是一个开源的商业产品,有两个版本:社区版(Community Edition,缩写为 CE)和企业版(Enterprise Edition,缩写为 EE)。 Docker CE 的安装请参考官方文档…...
Android Studio 中三方库依赖无法找到的解决方案
目录 错误信息解析 解决方案 1. 检查依赖版本 2. 检查 Maven 仓库配置 3. 强制刷新 Gradle 缓存 4. 检查网络连接 5. 手动下载依赖 总结 相关推荐 最近,我在编译一个 Android 老项目时遇到了一个问题,错误信息显示无法找到 com.gyf.immersionba…...
PGMP练-DAY24
DAY241A program has completed and closed. The training for the receiving organization has also delivered. But the stakeholders still concern that the benefits cannot be realized in long term.What does the program manager review to improve the situation?项…...
【C++动态规划 最长公共子序列】1035. 不相交的线|1805
本文涉及知识点 C动态规划 LeetCode1035. 不相交的线 在两条独立的水平线上按给定的顺序写下 nums1 和 nums2 中的整数。 现在,可以绘制一些连接两个数字 nums1[i] 和 nums2[j] 的直线,这些直线需要同时满足: nums1[i] nums2[j] 且绘制的…...
FFmpeg的基本结构
FFmpeg框架可以简单分为两层,上层是以ffmpeg、ffplay、ffprobe为代表的命令行工具;其底层支撑是一些基础库,包含AVFormat、AVCodec、AVFilter、AVDevices、AVUtils等模块库。 常用函数如下: 1. AVFormat 封装/解封装模块 avf…...
react 受控组件和非受控组件
在 React 中,受控组件和非受控组件是两种处理表单元素(如输入框、选择框等)值的方式。 1. 受控组件 受控组件是指 React 组件的表单元素的值是由 React 组件的 state 来管理的。换句话说,React 会全程控制表单元素的值ÿ…...
C语言模块化概述
一、函数名的意义 1.c语言是一门面向过程的语言:所谓的过程就是动词,动作。 功能块动词1动词2……动词 2.功能块:就是一堆动词(动作)的组合,动作通过函数来实现。 3.函数的功能:承上启下 承…...
WPF 中的视觉层和逻辑层有什么区别?
在 WPF(Windows Presentation Foundation)中,视觉层和逻辑层是两个不同的概念,它们分别涉及到界面的展示和应用的行为。要理解这两个层次的区别,我们需要从 WPF 的设计背景、架构以及它们之间的相互关系来全面分析。 …...
Kafka简单实践
使用 Apache Kafka 和 Swoole 的 PHP 实践案例 一、引言 Apache Kafka 是一个开源的分布式流处理平台,能够处理大量的实时数据流。由于其高吞吐量、可扩展性和持久性,Kafka 成为构建微服务架构和大数据处理的重要工具。Swoole 是一个高性能的异步网络通…...
JS
文章目录 项目地址一、JS1.1 if语句1.2 for循环1.2 三元表达式1.3 switch1.4 数组的push方法1.5 fuction1.5.1 arguments1.6 匿名函数1.7 预解析1.8 js对象1.8.1创建一个类1.8.2 遍历对象1.9 js的内置对象1.9.1 随机整数二、DOM2.1 获取元素2.2 事件基础2.2.1 事件三要素2.2.2 …...
【原创】java+ssm+mysql商品库存管理系统(进销存)设计与实现
个人主页:程序猿小小杨 个人简介:从事开发多年,Java、Php、Python、前端开发均有涉猎 博客内容:Java项目实战、项目演示、技术分享 文末有作者名片,希望和大家一起共同进步,你只管努力,剩下的交…...
three.js 杂记
欧拉角旋转变换 x,y,z 弧度单位 THREE.MathUtils.DEG2RAD 度数转弧度 new THREE.Euler( - 90 * THREE.MathUtils.DEG2RAD, 0, 0 ) radius:半径 setFromSphericalCoords ( radius : Float, phi : Float, theta : Float ) : this 从球坐标中的radius、phi和theta设置该向量…...
基于Hadoop、hive的数仓搭建实践
文章目录 架构图Hadoop搭建Hive 搭建MySQL搭建官网文档下载配置配置hive环境变量配置日志文件配置hive-site 复制mysql 驱动包删除日志包初始化元数据启动metastore服务使用hive CLI启动hiveServer2访问hiveserver2客户端连接beeline shell连接 Dbeaver连接经验 基于HDFS Hive…...
LFM2.5-1.2B-Thinking-GGUF部署指南:ss端口监听+curl health检测标准化运维流程
LFM2.5-1.2B-Thinking-GGUF部署指南:ss端口监听curl health检测标准化运维流程 1. 平台简介 LFM2.5-1.2B-Thinking-GGUF是Liquid AI推出的轻量级文本生成模型,特别适合在资源有限的环境中快速部署和使用。这个镜像内置了GGUF模型文件和llama.cpp运行时…...
数电课设实战:从555定时器到74LS190,手把手搭建一个密码锁系统
1. 密码锁系统设计概述 第一次接触数字电路课设时,我和大多数同学一样,面对一堆芯片和电路图完全无从下手。直到教授建议从密码锁这个经典项目入手,我才发现原来数电可以这么有趣。这个系统最精妙的地方在于,它把课本上枯燥的理论…...
零基础玩转VideoFusion:高效视频批量处理全攻略
零基础玩转VideoFusion:高效视频批量处理全攻略 【免费下载链接】VideoFusion 一站式短视频拼接软件 无依赖,点击即用,自动去黑边,自动帧同步,自动调整分辨率,批量变更视频为横屏/竖屏 项目地址: https://gitcode.com/gh_mirrors/vi/VideoFusion 在数字内容创…...
OpCore-Simplify:实现OpenCore EFI自动化生成的黑苹果配置解决方案
OpCore-Simplify:实现OpenCore EFI自动化生成的黑苹果配置解决方案 【免费下载链接】OpCore-Simplify A tool designed to simplify the creation of OpenCore EFI 项目地址: https://gitcode.com/GitHub_Trending/op/OpCore-Simplify 副标题:告别…...
ESP8266嵌入式JavaScript引擎:零内存分配的确定性JS执行
1. 项目概述 ESP8266-Arduino-JavaScript 是一个面向 ESP8266 平台的轻量级嵌入式 JavaScript 引擎库,其核心目标并非在微控制器上完整复刻 V8 或 SpiderMonkey 的功能,而是为资源受限的 IoT 设备提供一种 可预测、内存可控、无动态分配、零依赖 的脚本…...
毕业论文神器 2026 降AI率平台推荐:工具对比+最好用AI推荐
2026年真正好用的AI论文降重与改写工具,核心看降重效果、去AI味、格式保留、学术适配四大指标。综合实测,千笔AI、ThouPen、豆包、DeepSeek、Grammarly 是当前最值得推荐的梯队,覆盖从免费到付费、从中文到英文、从文科到理工的全场景需求。 …...
论文省心了!2026 最新降AI率工具测评与推荐
2026年真正好用的AI论文降重与改写工具,核心看降重效果、去AI味、格式保留、学术适配四大指标。综合实测,千笔AI、ThouPen、豆包、DeepSeek、Grammarly 是当前最值得推荐的梯队,覆盖从免费到付费、从中文到英文、从文科到理工的全场景需求。 …...
终极指南:nanoGPT如何让每个人都能训练自己的AI语言模型?
终极指南:nanoGPT如何让每个人都能训练自己的AI语言模型? 【免费下载链接】nanoGPT The simplest, fastest repository for training/finetuning medium-sized GPTs. 项目地址: https://gitcode.com/GitHub_Trending/na/nanoGPT 想要训练自己的AI…...
为什么流水线ADC能用Dither,而SAR ADC效果差?深入解析两种架构下的Dither技术差异与改进方案
流水线ADC与SAR ADC中Dither技术的差异化设计与工程实践 在高速高精度数据采集系统中,量化噪声的非线性特性始终是困扰设计者的核心难题。当我们用频谱分析仪观察一个理想正弦波经过ADC转换后的输出时,那些突兀的谐波分量往往源自量化过程的非线性失真。…...
保姆级教程:用snntorch在MNIST上训练你的第一个脉冲神经网络(附完整代码)
从零开始:用snntorch构建你的第一个脉冲神经网络手记 第一次接触脉冲神经网络(SNN)时,我被它模拟生物神经元放电的特性深深吸引。与传统人工神经网络不同,SNN通过离散的脉冲信号传递信息,更接近人脑的工作机…...
