private void ExpResPdf(Map<String, String> map) throws DocumentException {if (map == null) {map = new HashMap<String, String>();}// 生成文件的路径String outPdf = Constant.MUBAN + "救护记录单.pdf";// 获取模板的路径BaseFont bfChinese = null;try {// 对显示的语言进行初始化,设置样式// bfChinese = BaseFont.createFont("Helvetica", "Ansi",// BaseFont.NOT_EMBEDDED);// String path = FileUtils.getAssetFileContext(this,// "STFANGSO.TTF");String path = "file:///android_asset/Helvetica.Ttf";bfChinese = BaseFont.createFont(path, BaseFont.IDENTITY_H,BaseFont.NOT_EMBEDDED);} catch (DocumentException e) {// TODO Auto-generated catch blocke.printStackTrace();} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}Font FontChinese = new Font(bfChinese,12, Font.NORMAL);Font font8 = FontFactory.getFont(FontFactory.HELVETICA,8);// 设置标题的语言、大小、字体样式Font titleFont = new Font(bfChinese,16, Font.BOLD);// 标题// 设置表格标题的语言、大小、字体样式Font tableTitleFont = new Font(bfChinese,12, Font.BOLD);// 表格标题// 设置内容的语言、大小、字体样式Font conyentFont = new Font(bfChinese,12, Font.NORMAL);// 内容// 创建document对象Document document = new Document(PageSize.A4,50,50,50,50);// 获取操作pdf的实例(参数是document对象和文件输出流)try {PdfWriter writer = PdfWriter.getInstance(document,new FileOutputStream(outPdf));} catch (FileNotFoundException e) {// TODO Auto-generated catch blocke.printStackTrace();}// 实例化// 单元格PdfPCell cell = null;// 段落Paragraph tableTitle = null;// 打开之前设置参数HeaderFooter footer = new HeaderFooter(new Phrase("接诊人签名:                       接诊医师签名:                 ",conyentFont), false);document.setFooter(footer);document.open();// 添加标题Paragraph par = new Paragraph("云南省急救中心院前急救病例", tableTitleFont);par.setAlignment(Rectangle.ALIGN_CENTER);// par.setFirstLineIndent(15f);// 首行缩进// par.setSpacingBefore(15f);// 上留白par.setSpacingAfter(15f);// 上留白document.add(par);StringBuffer stringBuffer = new StringBuffer();String str = stringBuffer.append("站名: ").append(map.get("stationname")).append("   ").append("急救员救护性质: ").append(map.get("rescue_property")).append("   ").append("病案号: 暂无").toString();Paragraph zhanming = new Paragraph(str, conyentFont);zhanming.setSpacingAfter(15f);// 上留白document.add(zhanming);// 添加表格int myCol =3;// 创建表格对象,设置其为3列PdfPTable myTable = new PdfPTable(myCol);myTable.setHorizontalAlignment(Element.ALIGN_LEFT);myTable.setTotalWidth(500f);myTable.setWidths(new float[] {0.1f,0.1f,0.2f });myTable.setWidthPercentage(100);myTable.setLockedWidth(true);// 第一行StringBuffer stringBuffer2 = new StringBuffer();String strTableTitle = stringBuffer2.append("姓名: ").append(map.get("patient_name")).append("   ").append("性别: ").append(map.get("patient_sex")).append("   ").append("年龄: ").append(map.get("patient_age")).append("   ").append("单位: ").append(map.get("certificate_type")).append("   ").append("婚姻: ").append(map.get("patient_marry")).append("   ").toString();tableTitle = new Paragraph(strTableTitle, conyentFont);cell = new PdfPCell(tableTitle);cell.setVerticalAlignment(Element.ALIGN_MIDDLE);// 垂直居中cell.setColspan(3);// 跨3列// 将创建的这一列放到表格中myTable.addCell(cell);// 第二行StringBuffer stringBuffer3 = new StringBuffer();strTableTitle = stringBuffer3.append("职业: ").append(map.get("patient_job")).append("   ").append("民族: ").append(map.get("patient_nation")).append("   ").append("国籍: ").append(map.get("patient_nationality")).append("   ").append("电话: ").append(map.get("patient_phone")).append("   ").append("住址或单位: ").append(map.get("patient_address")).append("   ").toString();tableTitle = new Paragraph(strTableTitle, conyentFont);cell = new PdfPCell(tableTitle);cell.setVerticalAlignment(Element.ALIGN_MIDDLE);// 垂直居中cell.setColspan(3);// 跨3列// 将创建的这一列放到表格中myTable.addCell(cell);// 第三行StringBuffer stringBuffer4 = new StringBuffer();strTableTitle = stringBuffer4.append("出诊时间: ").append(map.get("out_patient_time")).append("   ").append("到达现场时间: ").append(map.get("arrive_spot_time")).append("   ").append("现场地址: ").append(map.get("spot_address")).append("   ").toString();tableTitle = new Paragraph(strTableTitle, conyentFont);cell = new PdfPCell(tableTitle);cell.setVerticalAlignment(Element.ALIGN_MIDDLE);// 垂直居中cell.setColspan(3);// 跨3列// 将创建的这一列放到表格中myTable.addCell(cell);// 第四行StringBuffer stringBuffer5 = new StringBuffer();strTableTitle = stringBuffer5.append("病史提供者: ").append(map.get("offer_history_person")).append("   ").append(map.get("patient_relation")).append("   ").append(map.get("patient_relation_other")).append("   ").toString();tableTitle = new Paragraph(strTableTitle, conyentFont);cell = new PdfPCell(tableTitle);cell.setVerticalAlignment(Element.ALIGN_MIDDLE);// 垂直居中cell.setColspan(3);// 跨3列// 将创建的这一列放到表格中myTable.addCell(cell);// 第五行StringBuffer stringBuffer6 = new StringBuffer();strTableTitle = stringBuffer6.append("既往史: ").append(map.get("past_history")).toString();tableTitle = new Paragraph(strTableTitle, conyentFont);cell = new PdfPCell(tableTitle);cell.setVerticalAlignment(Element.ALIGN_MIDDLE);// 垂直居中cell.setColspan(2);// 跨2列myTable.addCell(cell);// 第五行StringBuffer stringBuffer7 = new StringBuffer();strTableTitle = stringBuffer7.append("药物过敏史: ").append(map.get("irritability_history")).toString();tableTitle = new Paragraph(strTableTitle, conyentFont);cell = new PdfPCell(tableTitle);cell.setVerticalAlignment(Element.ALIGN_MIDDLE);// 垂直居中// cell.setColspan(2);// 跨2列myTable.addCell(cell);// 第六行StringBuffer stringBuffer8 = new StringBuffer();strTableTitle = stringBuffer8.append("主要体征: ").append("1.意识: ").append(map.get("main_awareness")).append("   ").append("2.T: ").append(map.get("physical_examination_temperatu")).append("℃").append("   ").append("P: ").append(map.get("physical_examination_pulse")).append("次/分").append("   ").append("R: ").append(map.get("physical_examination_heart")).append("次/分").append("   ").append("Bp: 收缩压: ").append(map.get("physical_examination_bp_high")).append("mmHg").append("   ").append("舒张压: ").append(map.get("physical_examination_bp_low")).append("mmHg").append("   ").append("3.其他: ").append(map.get("main_other_signs")).toString();tableTitle = new Paragraph(strTableTitle, conyentFont);cell = new PdfPCell(tableTitle);// cell.setHorizontalAlignment(Element.ALIGN_CENTER);// 水平居中cell.setVerticalAlignment(Element.ALIGN_MIDDLE);// 垂直居中cell.setColspan(3);// 跨3列myTable.addCell(cell);// 第七行StringBuffer stringBuffer9 = new StringBuffer();strTableTitle = stringBuffer9.append("患者主要情况: ").append(map.get("main_condition")).toString();tableTitle = new Paragraph(strTableTitle, conyentFont);cell = new PdfPCell(tableTitle);// cell.setHorizontalAlignment(Element.ALIGN_CENTER);// 水平居中cell.setVerticalAlignment(Element.ALIGN_MIDDLE);// 垂直居中cell.setColspan(3);// 跨3列myTable.addCell(cell);// 第七行 第一列strTableTitle = "辅助检查";tableTitle = new Paragraph(strTableTitle, conyentFont);cell = new PdfPCell(tableTitle);// cell.setHorizontalAlignment(Element.ALIGN_CENTER);// 水平居中cell.setVerticalAlignment(Element.ALIGN_MIDDLE);// 垂直居中myTable.addCell(cell);// 第七行 第二三列StringBuffer stringBuffer10 = new StringBuffer();strTableTitle = stringBuffer10.append("1.血氧饱和度: ").append(map.get("oxyhemoglobin_saturation")).append("%").append("   ").append("2.血糖: ").append(map.get("blood_glucose")).append("mmlo/h").append("   ").append("3.其他: ").append(map.get("main_other_signs")).toString();tableTitle = new Paragraph(strTableTitle, conyentFont);cell = new PdfPCell(tableTitle);// cell.setHorizontalAlignment(Element.ALIGN_CENTER);// 水平居中cell.setVerticalAlignment(Element.ALIGN_MIDDLE);// 垂直居中cell.setColspan(2);// 跨2列myTable.addCell(cell);// 第八行 第一列strTableTitle = "原诊断/初步印象";tableTitle = new Paragraph(strTableTitle, conyentFont);cell = new PdfPCell(tableTitle);// cell.setHorizontalAlignment(Element.ALIGN_CENTER);// 水平居中cell.setVerticalAlignment(Element.ALIGN_MIDDLE);// 垂直居中myTable.addCell(cell);// 第八行 第二三列StringBuffer stringBuffer11 = new StringBuffer();strTableTitle = stringBuffer11.append(map.get("first_impression")).toString();tableTitle = new Paragraph(strTableTitle, conyentFont);cell = new PdfPCell(tableTitle);// cell.setHorizontalAlignment(Element.ALIGN_CENTER);// 水平居中cell.setVerticalAlignment(Element.ALIGN_MIDDLE);// 垂直居中cell.setColspan(2);// 跨2列myTable.addCell(cell);// 第九行 第一列strTableTitle = "病情判断";tableTitle = new Paragraph(strTableTitle, conyentFont);cell = new PdfPCell(tableTitle);// cell.setHorizontalAlignment(Element.ALIGN_CENTER);// 水平居中cell.setVerticalAlignment(Element.ALIGN_MIDDLE);// 垂直居中myTable.addCell(cell);// 第九行 第二三列StringBuffer stringBuffer12 = new StringBuffer();strTableTitle = stringBuffer12.append(map.get("illness_judge")).toString();tableTitle = new Paragraph(strTableTitle, conyentFont);cell = new PdfPCell(tableTitle);// cell.setHorizontalAlignment(Element.ALIGN_CENTER);// 水平居中cell.setVerticalAlignment(Element.ALIGN_MIDDLE);// 垂直居中cell.setColspan(2);// 跨2列myTable.addCell(cell);// 第十行StringBuffer stringBuffer13 = new StringBuffer();strTableTitle = stringBuffer13.append("救护措施: ").append(map.get("rescue_measure")).append("   ").append(map.get("nurse_usematerial")).toString();tableTitle = new Paragraph(strTableTitle, conyentFont);cell = new PdfPCell(tableTitle);// cell.setHorizontalAlignment(Element.ALIGN_CENTER);// 水平居中cell.setVerticalAlignment(Element.ALIGN_MIDDLE);// 垂直居中cell.setColspan(3);// 跨3列myTable.addCell(cell);// 第十一行StringBuffer stringBuffer14 = new StringBuffer();strTableTitle = stringBuffer14.append("已告知患者/家属在现场救治、搬运和转送途中患者随时存在病情变化甚至恶化的可能,患方同意并要求送往 ").append(map.get("return_hospital")).append("医院/家中。已知晓患者情况我同意转送。").append("\n").append("患者或家属签名:              ").append("与患者关系: ").append(map.get("patient_relations")).append("      ").append("联系电话: ").append(map.get("patient_tel")).toString();tableTitle = new Paragraph(strTableTitle, conyentFont);cell = new PdfPCell(tableTitle);// cell.setHorizontalAlignment(Element.ALIGN_CENTER);// 水平居中cell.setVerticalAlignment(Element.ALIGN_MIDDLE);// 垂直居中cell.setColspan(3);// 跨3列myTable.addCell(cell);// 第十二行StringBuffer stringBuffer15 = new StringBuffer();strTableTitle = stringBuffer15.append("送达地点: ").append(map.get("detaildelivery_place")).append(" ").append(map.get("send_hospital")).append(" ").append(map.get("office")).append("   ").append("送达时间: ").append(map.get("send_arrival_time")).toString();tableTitle = new Paragraph(strTableTitle, conyentFont);cell = new PdfPCell(tableTitle);// cell.setHorizontalAlignment(Element.ALIGN_CENTER);// 水平居中cell.setVerticalAlignment(Element.ALIGN_MIDDLE);// 垂直居中cell.setColspan(3);// 跨3列myTable.addCell(cell);// 第十三行StringBuffer stringBuffer16 = new StringBuffer();strTableTitle = stringBuffer16.append("记录单完成时间: ").append(map.get("record_endtime")).append(" ").toString();tableTitle = new Paragraph(strTableTitle, conyentFont);cell = new PdfPCell(tableTitle);// cell.setHorizontalAlignment(Element.ALIGN_CENTER);// 水平居中cell.setVerticalAlignment(Element.ALIGN_MIDDLE);// 垂直居中cell.setColspan(3);// 跨3列myTable.addCell(cell);document.add(myTable);document.close();}

将数据以表格的形式保存到pdf中相关推荐

  1. R语言将多张可视化结果图像保存到PDF中实战:多图保存到同一PDF页、将多个绘图保存到PDF格式的不同页面

    R语言将多张可视化结果图像保存到PDF中实战:多图保存到同一PDF页.将多个绘图保存到PDF格式的不同页面 目录 R语言将多张可视化结果图像保存到PDF中实战:多图保存到同一PDF页.将多个绘图保存到 ...

  2. php获取表单后如何保存到数据库中,php – 如何将数据从HTML表单保存到WordPress中的数据库表?...

    我有一个WordPress主题,我正在尝试将数据从 HTML表单保存到数据库中. 我创建了HTML表单并添加了一个"save& close"按钮,该按钮调用名为saveDa ...

  3. python提取pdf表格数据并保存到excel中

    pdfplumber操作pdf文件 python开源库pdfplumber,可以较为方便地获取pdf的各种信息,包含pdf的基本信息(作者.创建时间.修改时间-)及表格.文本.图片等信息,基本可以满足 ...

  4. 怎么把matlab中的图导出,matlab的数据能保存到excel表格-如何将matlab 中输出的图形保存到Excel中去,详细点...

    怎样将MATLAB中的数据输出到excel中 数据保存到excel文件 xlswrite(xlsfile, data, sheet, range); % sheet 和 range可以不指定 如: x ...

  5. Python实现分析pdf或者Word形式简历,并且保存到Excel中

    Python实现分析当前文件夹里面所有的pdf或者Word形式简历,并且保存到Excel中 # -*- coding:utf-8 -*-#作者:公众号:湾区人工智能 #功能:实现分析pdf或者Word ...

  6. 爬取链家网二手房数据并保存到mongodb中

    提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 爬取链家网二手房数据并保存到mongodb中 文章目录 前言 一.爬虫的介绍 二.协程的介绍 三.css选择器 四.基于asyncio ...

  7. 把数据保存到cook_将用户信息保存到Cookie中

    /** * 把用户保存到Cookie * * @param request * @param response * @param member */ private void rememberPwdA ...

  8. STM32如何从串口接收数据,取出数据中的密码段再保存到flash中。

    STM32如何从串口接收数据,取出数据中的密码段再保存到flash中 STM32如何从串口接收数据,取出数据中的密码段再保存到flash中u8 Usart2_buf[256]; unsigned in ...

  9. python提取txt数据到excel_python 读取txt中每行数据,并且保存到excel中的实例

    使用xlwt读取txt文件内容,并且写入到excel中,代码如下,已经加了注释. 代码简单,具体代码如下: # coding=utf-8 ''' main function:主要实现把txt中的每行数 ...

最新文章

  1. leetcode006 zig_zig_print
  2. 每日一皮:自己运行正常,测试一测就有bug
  3. CVPR 2020 三篇有趣的论文解读
  4. boost::owner_less相关的测试程序
  5. 详解python 3下文本文件的编解码
  6. Linux有关Shell中if用法笔记
  7. OpenShift 4 - DevSecOps Workshop (15) - 利用OpenShift GitOps向多个目标部署应用
  8. macOS安装mysql后,进入mysql出现command not found
  9. GSM掉话原因(网优的基础知识)
  10. 华为mate8对flex的支持
  11. python的入门UDP编程
  12. input file 文件转base64
  13. 有线异步通信原理_全光纤网络结构原理是什么 全光纤网络结构原理介绍【详解】...
  14. Android手机管理工具类
  15. java程序员的cto成长之路
  16. 黑莓硌手的Passport变圆了
  17. leetcode 678 有效的括号字符串
  18. 【高等数学】函数连续、可导、可微,洛必达法则使用条件、一阶可导、一阶连续可导、二阶可导、二阶连续可导
  19. c语言键盘驱动程序,c语言键盘扫描程序
  20. 看漫画学python下载_用 Python 下载漫画

热门文章

  1. a8处理器相当于骁龙几_iPhone 8P相当于什么水平的安卓机?发现两点劣势,其它无关紧要...
  2. Google Play APK 下载
  3. 【笔记整理】图解设计模式 | 第16章 Mediator模式(只有一个仲裁者)
  4. 谷歌云端硬盘快速下载方法_如何快速搜索Google云端硬盘
  5. [kuangbin带你飞]专题四 最短路练习 R
  6. 操作系统 请求分页存储管理方式(含页面置换算法)
  7. echarts 报错Failed to execute 'createRadialGradient' on 'CanvasRenderingContext2D': The provided doubl
  8. Flink 运维与调优
  9. 开源网安实现高效、高精度的静态应用安全检测 -CodeSec
  10. 2022-2-13 转换函数(conversion function) non-explicit-one argument ctor explicit-one argument ctor