Unity之创建与导出PDF
内容将会持续更新,有错误的地方欢迎指正,谢谢!
拥有更好的学习体验 —— 不断努力,不断进步,不断探索 |
助力快速掌握 PDF 的创建与导出 为初学者节省宝贵的学习时间,避免困惑! |
TechX 教程效果:
文章目录
- 一、第三方库iTextSharp导入
- 1、通过Visual Studio的NuGet包管理器下载iTextSharp库
- 2、导入DLL文件到Unity中
- 二、使用iTextSharp生成和写入PDF文件的示例
- 三、写入和导出PDF实战
一、第三方库iTextSharp导入
在Unity中生成PDF文件并写入内容,需要使用第三方库,因为Unity本身不提供直接操作PDF的API。一个常用的库是iTextSharp,这是一个强大的PDF处理库。iTextSharp是iText的C#版本,可以用于创建、修改和读取PDF文档。
1、通过Visual Studio的NuGet包管理器下载iTextSharp库
-
打开NuGet包管理器:
在Visual Studio中,点击Tools菜单,选择NuGet Package Manager,然后选择Manage NuGet Packages for Solution…。
-
搜索iTextSharp:
在打开的NuGet包管理器窗口中,点击Browse选项卡,然后在搜索框中输入iTextSharp。
-
安装iTextSharp:
在搜索结果中找到iTextSharp包,点击Install按钮进行安装。根据提示完成安装过程。
2、导入DLL文件到Unity中
上一步下载的iTextSharp包在工程目录的Packages下,共包含两个文件夹:BouncyCastle.Cryptography.2.4.0和iTextSharp.5.5.13.4。
进入BouncyCastle.Cryptography.2.4.0\lib\net461和iTextSharp.5.5.13.4\lib\net461目录中找到BouncyCastle.Cryptography.dll和itextsharp.dll。
将两个DLL文件复制到你的Unity项目的Assets/Plugins文件夹中。如果没有Plugins文件夹,可以创建一个。
二、使用iTextSharp生成和写入PDF文件的示例
在Unity项目中创建一个C#脚本,例如PDFGenerator.cs。
在脚本中使用iTextSharp来生成和写入PDF。
以下是完整的示例代码:
using UnityEngine;
using System.IO;
using iTextSharp.text;
using iTextSharp.text.pdf;
using Image = iTextSharp.text.Image;public class PDFGenerator : MonoBehaviour
{void Start(){// 设置PDF保存路径string path = Application.dataPath + "/GeneratedPDF.pdf";// 图片路径string imgPath = Application.streamingAssetsPath+ "/path_to_image.jpg";using (FileStream fileStream = new FileStream(path, FileMode.Create)){// 创建一个文档对象Document document = new Document();// 创建一个PDF写入流PdfWriter pdfWriter = PdfWriter.GetInstance(document, fileStream );// 打开文档document.Open();// 添加内容到文档document.Add(new Paragraph("Hello, World!"));document.Add(new Paragraph("This is a PDF generated in Unity."));// 添加图片Image image = Image.GetInstance(imgPath );document.Add(image);// 添加表格PdfPTable table = new PdfPTable(3); // 3列的表格table.AddCell("Cell 1");table.AddCell("Cell 2");document.Add(table);//关闭写入流pdfWriter.Close();// 关闭文档document.Close();}Debug.Log("PDF generated at: " + path);}
}
三、写入和导出PDF实战
using System.IO;
using iTextSharp.text;
using iTextSharp.text.pdf;
using UnityEngine;
using Font = iTextSharp.text.Font;
using Rectangle = iTextSharp.text.Rectangle;namespace PDFExport
{/// <summary>/// PDF文档操作类/// </summary>public class PDFOperation{#region 私有字段private Font font = default;private PdfWriter pdfWriter;private Rectangle documentSize; //文档大小private Document document;//文档对象private BaseFont basefont;//字体#endregion#region 构造函数/// <summary>/// 构造函数/// </summary>public PDFOperation(){documentSize = PageSize.A4;document = new Document(documentSize);}/// <summary>/// 构造函数/// </summary>/// <param name="type">页面大小(如"A4")</param>public PDFOperation(Rectangle size){documentSize = size;document = new Document(size);}/// <summary>/// 构造函数/// </summary>/// <param name="type">页面大小(如"A4")</param>/// <param name="marginLeft">内容距左边框距离</param>/// <param name="marginRight">内容距右边框距离</param>/// <param name="marginTop">内容距上边框距离</param>/// <param name="marginBottom">内容距下边框距离</param>public PDFOperation(Rectangle size, float marginLeft, float marginRight, float marginTop, float marginBottom){documentSize = size;document = new Document(size, marginLeft, marginRight, marginTop, marginBottom);}#endregion#region 文档操作/// <summary>/// 创建写入流/// </summary>/// <param name="os">文档相关信息(如路径,打开方式等)</param>public PdfWriter OpenPdfWriter(FileStream os){pdfWriter = PdfWriter.GetInstance(document, os);return pdfWriter;}/// <summary>/// 关闭写入流/// </summary>/// <param name="writer"></param>public void ClosePdfWriter(){pdfWriter.Close();}/// <summary>/// 打开文档/// </summary>public void Open(){document.Open();}/// <summary>/// 关闭打开的文档/// </summary>public void Close(){document.Close();}#endregion#region 设置字体/// <summary>/// 设置字体/// </summary>public void SetBaseFont(string path){basefont = BaseFont.CreateFont(path, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);}/// <summary>/// 设置字体/// </summary>/// <param name="size">字体大小</param>public Font SetFont(float size){font = new Font(basefont, size);return font;}/// <summary>/// 设置字体/// </summary>/// <param name="size"></param>/// <param name="style"></param>public Font SetFont(float size, int style){font = new Font(basefont, size, style);return font;}/// <summary>/// 设置字体/// </summary>/// <param name="size"></param>/// <param name="style"></param>/// <param name="fontColor"></param>public Font SetFont(float size, int style, BaseColor fontColor){font = new Font(basefont, size, style, fontColor);return font;}/// <summary>/// 获取字体/// </summary>/// <returns></returns>public Font GetFont(){return font;}#endregionpublic void AddPage(){document.NewPage();}#region 添加段落/// <summary>/// 空格/// 加入空行,用以区分上下行/// </summary>public void AddNullLine(int nullLine=1,int lightHeight=12){// Change this to the desired number of empty linesint numberOfEmptyLines = nullLine; for (int i = 0; i < numberOfEmptyLines; i++){Paragraph emptyLine = new Paragraph(" ", new Font(Font.FontFamily.HELVETICA, lightHeight));document.Add(emptyLine);}}/// <summary>/// 插入文字内容/// </summary>/// <param name="content">内容</param>/// <param name="alignmentType">对齐格式,0为左对齐,1为居中</param>/// <param name="indent">首行缩进</param>public void AddParagraph(string content, int alignmentType = 0,float indent = 0){Paragraph contentP = new Paragraph(new Chunk(content, font));contentP.FirstLineIndent = indent;contentP.Alignment = alignmentType;document.Add(contentP);}/// <summary>/// 添加段落/// </summary>/// <param name="content">内容</param>/// <param name="Alignment">对齐方式(1为居中,0为居左,2为居右)</param>/// <param name="SpacingAfter">段后空行数(0为默认值)</param>/// <param name="SpacingBefore">段前空行数(0为默认值)</param>/// <param name="MultipliedLeading">行间距(0为默认值)</param>public void AddParagraph(string content, int Alignment, float SpacingAfter, float SpacingBefore, float MultipliedLeading){Paragraph pra = new Paragraph(content, font);pra.Alignment = Alignment;if (SpacingAfter != 0){pra.SpacingAfter = SpacingAfter;}if (SpacingBefore != 0){pra.SpacingBefore = SpacingBefore;}if (MultipliedLeading != 0){pra.MultipliedLeading = MultipliedLeading;}document.Add(pra);}#endregion#region 添加图片/// <summary>/// 添加图片/// </summary>/// <param name="path">图片路径</param>/// <param name="Alignment">对齐方式(1为居中,0为居左,2为居右)</param>/// <param name="newWidth">图片宽(0为默认值,如果宽度大于页宽将按比率缩放)</param>/// <param name="newHeight">图片高</param>public Image AddImage(string imagePath, int Alignment, float newWidth, float newHeight){if (!File.Exists(imagePath)){Debug.Log("该路径下不存在指定图片,请检测路径是否正确!");return null;}Image img = Image.GetInstance(imagePath);img.Alignment = Alignment;if (newWidth != 0){img.ScaleAbsolute(newWidth, newHeight);}else{if (img.Width > PageSize.A4.Width){img.ScaleAbsolute(documentSize.Width, img.Width * img.Height / documentSize.Height);}}document.Add(img);return img;}/// <summary>/// 添加图片/// </summary>/// <param name="path">图片路径</param>/// <param name="Alignment">对齐方式(1为居中,0为居左,2为居右)</param>/// <param name="newWidth">图片宽</param>/// <param name="newHeight">图片高</param>public Image AddImage(string imagePath, int Alignment, int fitWidth, int fitHeight){if (!File.Exists(imagePath)){Debug.Log("该路径下不存在指定图片,请检测路径是否正确!");return null;}Image image = Image.GetInstance(imagePath);image.ScaleToFit(fitWidth, fitHeight);image.Alignment = Alignment;document.Add(image);return image;}#endregion #region Table表public void AddTable(PdfPTable table){document.Add(table);}#endregion}
}
using iTextSharp.text;
using iTextSharp.text.pdf;
using System;
using System.IO;
using UnityEditor;
using UnityEngine;
using Font = iTextSharp.text.Font;
using Image = iTextSharp.text.Image;namespace PDFExport
{public class ReportExporterPDF: MonoBehaviour{private string fontPath = Application.streamingAssetsPath + "/Fonts/SIMFANG.TTF";string imagePath1 = Application.streamingAssetsPath + "/Images/logo.png";private void Start(){GenerateReportPDF();}public void GenerateReportPDF(){CreatePDF(Application.streamingAssetsPath + "/Report.pdf");}private void CreatePDF(string filePath){using (FileStream fileStream = new FileStream(filePath, FileMode.Create)){PDFOperation pdf = new PDFOperation(PageSize.A4, 55f, 55f, 96f, 96f);pdf.SetBaseFont(fontPath);PdfWriter pdfWriter = pdf.OpenPdfWriter(fileStream);pdf.Open();HeaderFooterPageEvent headerFooterPageEvent = new HeaderFooterPageEvent(pdf,this);pdfWriter.PageEvent = headerFooterPageEvent;FirstPasge(pdf);pdf.Close();pdf.ClosePdfWriter();
#if UNITY_EDITORAssetDatabase.Refresh();
#endif}Application.OpenURL(filePath);}#region FirstPageprivate void FirstPasge(PDFOperation pdf){pdf.AddNullLine(1, 22);Image image1 = Image.GetInstance(imagePath1);PdfPTable table = new PdfPTable(1);table.DefaultCell.Border = Rectangle.NO_BORDER;table.DefaultCell.Padding = 0;table.DefaultCell.FixedHeight = 100;// 设置图片的缩放比例float scale = 0.9f;image1.ScaleAbsolute(image1.Width * scale, image1.Height * scale);PdfPCell cell1 = new PdfPCell(image1);cell1.HorizontalAlignment = 1;cell1.PaddingRight = 0;cell1.Border = Rectangle.NO_BORDER;table.AddCell(cell1);pdf.AddTable(table);pdf.AddNullLine();pdf.SetFont(24);pdf.AddParagraph("汽车实验系统", 1);pdf.AddNullLine();pdf.SetFont(36, Font.BOLD);pdf.AddParagraph("实验报告", 1);pdf.AddNullLine(3);AddMainInfo(pdf);}public void AddMainInfo(PDFOperation pdf){// 创建一个有 2 列的表格float[] columnWidths = { 124, 369 };PdfPTable table = new PdfPTable(columnWidths);table.DefaultCell.Border = Rectangle.NO_BORDER;// 设置表格宽度和对齐方式table.WidthPercentage = 80;table.HorizontalAlignment = Element.ALIGN_CENTER;string[] cellContents = {"实验名称:", "汽车仿真实验","实验地点:", "","学生姓名:", "","指导教师:", "","所属单位:", "","支持单位:", "XXXX科技大学","支持单位:", "XXXXXX股份有限公司","实验时间:", DateTime.Now.ToString("yyyy年MM月dd日")};// 用提供的信息添加表格单元格for (int i = 0; i < cellContents.Length; i++){PdfPCell cell;if (i % 2 == 0){pdf.SetFont(14, Font.BOLD);cell = new PdfPCell(new Phrase(cellContents[i], pdf.GetFont()));}else{pdf.SetFont(14, Font.NORMAL);cell = new PdfPCell(new Phrase(cellContents[i], pdf.GetFont()));}cell.Padding = 10;cell.Border = Rectangle.NO_BORDER;table.AddCell(cell);}pdf.AddTable(table);}#endregion#region 页眉页脚public class HeaderFooterPageEvent : PdfPageEventHelper{PDFOperation pdf;ReportExporterPDF reportExporter;public HeaderFooterPageEvent(PDFOperation pdf, ReportExporterPDF reportExporter){this.pdf = pdf;this.reportExporter = reportExporter;}public override void OnEndPage(PdfWriter writer, Document doc){base.OnEndPage(writer, doc);Header(writer, doc);Footer(writer, doc);}private void Header(PdfWriter writer, Document doc){float[] columnWidths = { 25, 200 };// 添加带图片和文字的页眉PdfPTable headerTable = new PdfPTable(columnWidths);headerTable.DefaultCell.Border = Rectangle.NO_BORDER;headerTable.WidthPercentage = 100;headerTable.HorizontalAlignment = Element.ALIGN_CENTER;headerTable.TotalWidth = doc.PageSize.Width - doc.LeftMargin - doc.RightMargin; // Set table widthheaderTable.LockedWidth = true; // Lock the table widthImage image1 = Image.GetInstance(reportExporter.imagePath1);// Add images to the headerimage1.ScaleAbsolute(image1.Width / 2, image1.Height / 2);PdfPCell imageCell1 = new PdfPCell(image1);imageCell1.Border = Rectangle.NO_BORDER;// Add text to the headerpdf.SetFont(10, Font.NORMAL, BaseColor.GRAY);Font headerFont = pdf.GetFont();PdfPCell textCell = new PdfPCell(new Phrase("XXXXXX股份有限公司", headerFont));textCell.HorizontalAlignment = Element.ALIGN_RIGHT;textCell.VerticalAlignment = Element.ALIGN_BOTTOM;textCell.Border = Rectangle.NO_BORDER;headerTable.AddCell(imageCell1);headerTable.AddCell(textCell);headerTable.WriteSelectedRows(0, -1, doc.Left, doc.Top + 60, writer.DirectContent);}private void Footer(PdfWriter writer, Document doc){// Add footer with page numberPdfPTable footerTable = new PdfPTable(1);footerTable.DefaultCell.Border = Rectangle.NO_BORDER;footerTable.WidthPercentage = 100;footerTable.HorizontalAlignment = Element.ALIGN_CENTER;footerTable.TotalWidth = doc.PageSize.Width - doc.LeftMargin - doc.RightMargin; // Set table widthfooterTable.LockedWidth = true; // Lock the table widthint pageNumber = writer.PageNumber;int totalPages = writer.CurrentPageNumber; // Exclude the cover pagepdf.SetFont(9, Font.NORMAL, BaseColor.GRAY);Font footFont = pdf.GetFont();PdfPCell footerCell = new PdfPCell(new Phrase($"{totalPages}", footFont));footerCell.HorizontalAlignment = Element.ALIGN_CENTER;footerCell.Border = Rectangle.NO_BORDER;footerTable.AddCell(footerCell);footerTable.WriteSelectedRows(0, -1, doc.Left, doc.Bottom - 50, writer.DirectContent);}}#endregion}
}
每一次跌倒都是一次成长 每一次努力都是一次进步 |
如果您喜欢本博客,请点赞和分享给更多的朋友,让更多人受益。同时,您也可以关注我的博客,以便及时获取最新的更新和文章。
在未来的写作中,我将继续努力,分享更多有趣、实用的内容。再次感谢大家的支持和鼓励,期待与您在下一篇博客再见!
相关文章:

Unity之创建与导出PDF
内容将会持续更新,有错误的地方欢迎指正,谢谢! Unity之创建与导出PDF TechX 坚持将创新的科技带给世界! 拥有更好的学习体验 —— 不断努力,不断进步,不断探索 TechX —— 心探索、心进取! 助力快速…...

【Android面试八股文】优化View层次过深问题,选择哪个布局比较好?
优化深层次View层次结构的问题,选择合适的布局方式是至关重要的。以下是几点建议: 使用ConstraintLayout:ConstraintLayout是Android开发中推荐的布局,能够有效减少嵌套,提高布局性能。相比RelativeLayout,…...

什么是带有 API 网关的代理?
带有 API 网关的代理服务显著提升了用户体验和性能。特别是对于那些使用需要频繁创建和轮换代理的工具的用户来说,使用 API 可以节省大量时间并提高效率。 了解 API API,即应用程序编程接口,是服务提供商和用户之间的连接网关。通过 API 连接…...

sql拉链表
1、定义:维护历史状态以及最新数据的一种表 2、使用场景 1、有一些表的数据量很大,比如一张用户表,大约1亿条记录,50个字段,这种表 2.表中的部分字段会被update更新操作,如用户联系方式,产品的…...

STM32CubeMX实现矩阵按键(HAL库实现)
功能描述: 实现矩阵按键验证,将矩阵按键的按键值,通过串口显示,便于后面使用。 实物图 原理图: 编程原理: 原理很简单,就是通过循环设置引脚为低电平,另外引脚扫描读取电平值&…...

mmdetection3D指定版本安装指南
1. 下载指定版本号 选择指定版本号下载mmdetection3d的源码,如这里选择的是0.17.2版本 git clone https://github.com/open-mmlab/mmdetection3d.git -b v0.17.22. 安装 cd mmdetection3d安装依赖库 pip install -r requirment.txt编译安装 pip install -v e .…...

SQLMap工具详解与SQL注入防范
SQLMap工具详解与SQL注入防范 大家好,我是微赚淘客系统3.0的小编,也是冬天不穿秋裤,天冷也要风度的程序猿!今天我们将深入探讨SQLMap工具的详细使用方法以及如何防范SQL注入攻击。 SQL注入简介 SQL注入是一种常见的安全漏洞&am…...

如何在Java中实现自定义数据结构:从头开始
如何在Java中实现自定义数据结构:从头开始 大家好,我是免费搭建查券返利机器人省钱赚佣金就用微赚淘客系统3.0的小编,也是冬天不穿秋裤,天冷也要风度的程序猿!今天我们将探讨如何在Java中实现自定义数据结构ÿ…...

【机器学习】在【Pycharm】中的应用:【线性回归模型】进行【房价预测】
专栏:机器学习笔记 pycharm专业版免费激活教程见资源,私信我给你发 python相关库的安装:pandas,numpy,matplotlib,statsmodels 1. 引言 线性回归(Linear Regression)是一种常见的统计方法和机器学习算法&a…...

如何在 Linux 中后台运行进程?
一、后台进程 在后台运行进程是 Linux 系统中的常见要求。在后台运行进程允许您在进程独立运行时继续使用终端或执行其他命令。这对于长时间运行的任务或当您想要同时执行多个命令时特别有用。 在深入研究各种方法之前,让我们先了解一下什么是后台进程。在 Linux 中…...

软考-软件设计师
软考 软考科目 软考分为初级、中级、高级,初级含金量相对不够,高级考试有难度,所以大多数人都在考中级,中级也分很多科目,我考的是软件设计师(已经通过)。 合格标准 考试分为上午题和下午题…...

UOS系统中JavaFx笔锋功能
关于笔锋功能,网上找了很久,包括Java平台客户端,Android端,相关代码资料比较少,找了很多经过测试效果都差强人意,自己也搓不出来,在UOS平台上JavaFX也获取不到压力值,只能用速度的变…...

后端加前端Echarts画图示例全流程(折线图,饼图,柱状图)
本文将带领读者通过一个完整的Echarts画图示例项目,演示如何结合后端技术(使用Spring Boot框架)和前端技术(使用Vue.js或React框架)来实现数据可视化。我们将实现折线图、饼图和柱状图三种常见的数据展示方式ÿ…...

ValidateAntiForgeryToken、AntiForgeryToken 防止CSRF(跨网站请求伪造)
用途:防止CSRF(跨网站请求伪造)。 用法:在View->Form表单中: aspx:<%:Html.AntiForgeryToken()%> razor:Html.AntiForgeryToken() 在Controller->Action动作上:[ValidateAntiForge…...

《昇思25天学习打卡营第5天 | mindspore 网络构建 Cell 常见用法》
1. 背景: 使用 mindspore 学习神经网络,打卡第五天; 2. 训练的内容: 使用 mindspore 的 nn.Cell 构建常见的网络使用方法; 3. 常见的用法小节: 支持一系列常用的 nn 的操作 3.1 nn.Cell 网络构建&…...

SQLServer:从数据类型 varchar 转换为 numeric 时出错。
1.工作要求 计算某两个经纬度距离 2.遇到问题 从数据类型 varchar 转换为 numeric 时出错。 3.解决问题 项目版本较老,使用SQLServer 2012 计算距离需执行视图,如下: SET QUOTED_IDENTIFIER ON SET ANSI_NULLS ON GO ALTER view vi_ord…...

探索迁移学习:通过实例深入理解机器学习的强大方法
探索迁移学习:通过实例深入理解机器学习的强大方法 🍁1. 迁移学习的概念🍁2. 迁移学习的应用领域🍁2.1 计算机视觉🍁2.2 自然语言处理(NLP)🍁2.3 医学图像分析🍁2.4 语音…...

【Linux】性能分析器 perf 详解(四):trace
上一篇:【Linux】性能分析器 perf 详解(三) 1、trace 1.1 简介 perf trace 类似于 strace 工具:用于对Linux系统性能分析和调试的工具。 原理是:基于 Linux 性能计数器(Performance Counters for Linux, PCL),监控和记录系统调用和其他系统事件。 可以提供关于硬件…...

信息安全体系架构设计
对信息系统的安全需求是任何单一安全技术都无法解决的,要设计一个信息安全体系架构,应当选择合适的安全体系结构模型。信息系统安全设计重点考虑两个方面;其一是系统安全保障体系;其二是信息安全体系架构。 1.系统安全保障体系 安…...

GPT-5即将登场:AI赋能下的未来工作与日常生活新图景
随着OpenAI首席技术官米拉穆拉蒂在近期采访中的明确表态,GPT-5的发布已不再是遥不可及的梦想,而是即将在一年半后与我们见面的现实。这一消息无疑在科技界乃至全社会引发了广泛关注和热烈讨论。从GPT-4到GPT-5的飞跃,被形容为从高中生到博士生…...

RocketMQ实战:一键在docker中搭建rocketmq和doshboard环境
在本篇博客中,我们将详细介绍如何在 Docker 环境中一键部署 RocketMQ 和其 Dashboard。这个过程基于一个预配置的 Docker Compose 文件,使得部署变得简单高效。 项目介绍 该项目提供了一套 Docker Compose 配置,用于快速部署 RocketMQ 及其…...

前端项目vue3/React使用pako库解压缩后端返回gzip数据
pako仓库地址:https://github.com/nodeca/pako 文档地址:pako 2.1.0 API documentation 外部接口返回一个直播消息或者图片数据是经过zip压缩的,前端需要把这个数据解压缩之后才可以使用,这样可以大大降低网络数据传输的内容&…...

C++专业面试真题(1)学习
TCP和UDP区别 TCP 面向连接。在传输数据之前,通信双方需要先建立一个连接(三次握手)。可靠性。TCP提供可靠的数据传输,它通过序列号、确认应答、重传机制和校验和等技术确保数据的正确传输。数据顺序:TCP保证数据按发…...

2024 年人工智能和数据科学的五个主要趋势
引言 2023年,人工智能和数据科学登上了新闻头条。生成性人工智能的兴起无疑是这一显著提升曝光度的驱动力。那么,在2024年,该领域将如何继续占据头条,并且这些趋势又将如何影响企业的发展呢? 在过去几个月,…...

GPU云渲染平台到底怎么选?这六点要注意!
随着对高效计算和图像处理需求的增加,GPU云渲染平台成为许多行业的关键工具。尤其是对影视动画制作领域来说,选择一个合适的GPU云渲染平台可以大大提升工作效率。然而,面对市场上众多的选择,如何找到适合自己的GPU云渲染平台呢&am…...

【区块链+基础设施】国家健康医疗大数据科创平台 | FISCO BCOS应用案例
在医疗领域,疾病数据合法合规共享是亟待解决的难题。一方面,当一家医院对患者实施治疗后,若患者转到其 他医院就医,该医院就无法判断诊疗手段是否有效。另一方面,医疗数据属于个人敏感数据,一旦被泄露或被恶…...

redis压测和造数据方式
一、redis 压测工具 1、压测命令 1、对3000字节的数据进行get set的操作 redis-benchmark -h 10.166.15.36 -p 7001 -t set,get -n 100000 -q -d 3000 2、100个并发连接,100000个请求,检测host为localhost 端口为6379的redis服务器性能 redis-benchma…...

数据存储方案选择:ES、HBase、Redis、MySQL与MongoDB的应用场景分析
一、概述 1.1 背景 在当今数据驱动的时代,选择合适的数据存储技术对于构建高效、可靠的信息系统至关重要。随着数据量的爆炸式增长和处理需求的多样化,市场上涌现出了各种数据存储解决方案,每种技术都有其独特的优势和适用场景。Elasticsear…...

数组理论基础
1. **数组定义**: - 数组是存放在连续内存空间上的相同类型数据的集合。 2. **数组特性**: - 数组下标从0开始。 - 数组的内存空间地址是连续的。 3. **数组操作**: - 数组可以通过下标索引快速访问元素。 - 数组元素的删除…...

FlinkCDC 数据同步优化及常见问题排查
【面试系列】Swift 高频面试题及详细解答 欢迎来到我的博客,很高兴能够在这里和您见面!欢迎订阅相关专栏: 欢迎关注微信公众号:野老杂谈 ⭐️ 全网最全IT互联网公司面试宝典:收集整理全网各大IT互联网公司技术、项目、…...