当前位置: 首页 > news >正文

山东通app下载安装2022简述什么是seo及seo的作用

山东通app下载安装2022,简述什么是seo及seo的作用,中企动力 网站建设,生产管理软件哪家好PDF修改尺寸 需要注意:第一个方法返回的是转换后PDF的base64。第二个方法返回的是文件流,这个方法才是转的核心。 /*** 修改PDF尺寸** param pdfUrl PDF链接* param pdfWidthInMillimeters 指定宽 mm* param pdfHeightInMillimeters 指…

PDF修改尺寸

需要注意:第一个方法返回的是转换后PDF的base64。第二个方法返回的是文件流,这个方法才是转的核心。

 /*** 修改PDF尺寸** @param pdfUrl                 PDF链接* @param pdfWidthInMillimeters  指定宽 mm* @param pdfHeightInMillimeters 指定高 mm* @return PDF转换尺寸后的base64*/public static String updatePdfSize(String pdfUrl, float pdfWidthInMillimeters, float pdfHeightInMillimeters) {try {URL url = new URL(pdfUrl);HttpURLConnection conn = (HttpURLConnection) url.openConnection();conn.setRequestMethod("GET");conn.setConnectTimeout(5000);InputStream is = conn.getInputStream();ByteArrayOutputStream out = updatePdfSize(is, pdfWidthInMillimeters, pdfHeightInMillimeters);BASE64Encoder encoder = new BASE64Encoder();String pdfBase64 = encoder.encode(out.toByteArray());is.close();return pdfBase64;} catch (IOException e) {log.error("updatePdfSize error:{}", e.getMessage(), e);}return "";}/*** 转换PDF尺寸** @param inputStream            PDF源文件流* @param pdfWidthInMillimeters  指定宽 mm* @param pdfHeightInMillimeters 指定高 mm* @return 转换后的PDF的文件流*/public static ByteArrayOutputStream updatePdfSize(InputStream inputStream, float pdfWidthInMillimeters, float pdfHeightInMillimeters) {try {// 毫米转换为磅(1毫米≈2.83465磅)float pdfWidthInPoints = pdfWidthInMillimeters * 2.83465f;float pdfHeightInPoints = pdfHeightInMillimeters * 2.83465f;//  容器初始化ByteArrayOutputStream out = new ByteArrayOutputStream();Document doc = new Document();PdfWriter writer = PdfWriter.getInstance(doc, out);doc.open();PdfReader pdfReader = new PdfReader(inputStream);PdfContentByte cb = writer.getDirectContent();// 循环修改尺寸int total = pdfReader.getNumberOfPages();for (int i = 1; i <= total; i++) {PdfImportedPage page = writer.getImportedPage(pdfReader, i);Rectangle rectangle = pdfReader.getPageSize(i);float originalWidth = rectangle.getWidth();float originalHeight = rectangle.getHeight();// 计算缩放比例float scaleWidth = pdfWidthInPoints / originalWidth;float scaleHeight = pdfHeightInPoints / originalHeight;float scale = Math.min(scaleWidth, scaleHeight);doc.setPageSize(new RectangleReadOnly(originalWidth * scale, originalHeight * scale));doc.newPage();cb.addTemplate(page, scale, 0, 0, scale, 0, 0);}doc.close();writer.close();return out;} catch (Exception e) {log.error("updatePdfSize error:{}", e.getMessage(), e);return null;}}

图片转成指大小PDF

返回的是base64。需要返回流的,可能简单改写下

/*** 图片转成指定大小的PDF的base64** @param pngImagePath           图片地址* @param pdfWidthInMillimeters  指定的PDF宽(mm)* @param pdfHeightInMillimeters 指定的PDF高(mm)* @return PDF的Base64*/public static String convertPngToPdfBase64(String pngImagePath, float pdfWidthInMillimeters, float pdfHeightInMillimeters) {try {// 毫米转换为磅(1毫米≈2.83465磅)float pdfWidthInPoints = pdfWidthInMillimeters * 2.83465f;float pdfHeightInPoints = pdfHeightInMillimeters * 2.83465f;// 读取PNG图像的原始宽度和高度(单位:点)Image pngImage = Image.getInstance(pngImagePath);float originalWidth = pngImage.getWidth();float originalHeight = pngImage.getHeight();// 计算图像在PDF中的缩放比例float scaleWidth = pdfWidthInPoints / originalWidth;float scaleHeight = pdfHeightInPoints / originalHeight;float scale = Math.min(scaleWidth, scaleHeight);// 计算图像在PDF中的位置居中显示float xPosition = (pdfWidthInPoints - originalWidth * scale) / 2;float yPosition = (pdfHeightInPoints - originalHeight * scale) / 2;// 创建Document对象,并设置PDF文档的大小为所需尺寸Document document = new Document(new Rectangle(pdfWidthInPoints, pdfHeightInPoints));// 创建PdfWriter对象,将输出流与Document对象关联ByteArrayOutputStream os = new ByteArrayOutputStream();PdfWriter.getInstance(document, os);// 打开Documentdocument.open();// 设置PNG图像在PDF中的缩放比例和位置pngImage.scaleAbsolute(originalWidth * scale, originalHeight * scale);pngImage.setAbsolutePosition(xPosition, yPosition);// 将PNG图像添加到PDF中document.add(pngImage);// 关闭Documentdocument.close();// 返回PDF的base64return new BASE64Encoder().encode(os.toByteArray()).trim().replaceAll("\\r", "").replaceAll("\\n", "");} catch (DocumentException | IOException e) {log.error("image 转 pdf 流失败 {}", e.getMessage(), e);return "";}}

文章转载自:
http://dinncobestiality.wbqt.cn
http://dinncodecimetre.wbqt.cn
http://dinncoalcor.wbqt.cn
http://dinncocandelabra.wbqt.cn
http://dinncosupervisal.wbqt.cn
http://dinncofluty.wbqt.cn
http://dinncosawblade.wbqt.cn
http://dinncodichasial.wbqt.cn
http://dinnconotum.wbqt.cn
http://dinncofootlights.wbqt.cn
http://dinncoproducible.wbqt.cn
http://dinncoepiglottis.wbqt.cn
http://dinncospiciform.wbqt.cn
http://dinncointendant.wbqt.cn
http://dinncomonocracy.wbqt.cn
http://dinncotack.wbqt.cn
http://dinncofranc.wbqt.cn
http://dinncopentoxide.wbqt.cn
http://dinncoextraliterary.wbqt.cn
http://dinncomayanist.wbqt.cn
http://dinncoxenophobe.wbqt.cn
http://dinncobacteric.wbqt.cn
http://dinncovlcc.wbqt.cn
http://dinncocobia.wbqt.cn
http://dinncoeudemonia.wbqt.cn
http://dinncofadayeen.wbqt.cn
http://dinncononpolar.wbqt.cn
http://dinncotuesdays.wbqt.cn
http://dinncotheophagy.wbqt.cn
http://dinncoholddown.wbqt.cn
http://dinncowollongong.wbqt.cn
http://dinncoatwitch.wbqt.cn
http://dinncoreluctivity.wbqt.cn
http://dinncosomatogenetic.wbqt.cn
http://dinncoreaffirmation.wbqt.cn
http://dinncoblustery.wbqt.cn
http://dinncoganglionate.wbqt.cn
http://dinncoencopresis.wbqt.cn
http://dinncosourcebook.wbqt.cn
http://dinncochampak.wbqt.cn
http://dinncokeratinization.wbqt.cn
http://dinncosciatica.wbqt.cn
http://dinncosequential.wbqt.cn
http://dinncobraw.wbqt.cn
http://dinncoleif.wbqt.cn
http://dinncobrightly.wbqt.cn
http://dinncoperchance.wbqt.cn
http://dinncocringle.wbqt.cn
http://dinncoconcoctive.wbqt.cn
http://dinncodehydratase.wbqt.cn
http://dinncomotiveless.wbqt.cn
http://dinncomythicize.wbqt.cn
http://dinncoretinacular.wbqt.cn
http://dinncocertainly.wbqt.cn
http://dinncopuritan.wbqt.cn
http://dinncogenette.wbqt.cn
http://dinncovileness.wbqt.cn
http://dinncotheatromania.wbqt.cn
http://dinncodrawgate.wbqt.cn
http://dinncovdr.wbqt.cn
http://dinncolima.wbqt.cn
http://dinncostress.wbqt.cn
http://dinncocamerlingate.wbqt.cn
http://dinncotheogony.wbqt.cn
http://dinncounsound.wbqt.cn
http://dinncoeasternize.wbqt.cn
http://dinncoblackwash.wbqt.cn
http://dinncosupercurrent.wbqt.cn
http://dinncominty.wbqt.cn
http://dinncowad.wbqt.cn
http://dinncodeepfry.wbqt.cn
http://dinncopamlico.wbqt.cn
http://dinncoblow.wbqt.cn
http://dinncodiammonium.wbqt.cn
http://dinncoenamine.wbqt.cn
http://dinncopollen.wbqt.cn
http://dinncogilt.wbqt.cn
http://dinncospecialise.wbqt.cn
http://dinncovotive.wbqt.cn
http://dinncounemployable.wbqt.cn
http://dinncotetanus.wbqt.cn
http://dinncolepidopterous.wbqt.cn
http://dinncocornelia.wbqt.cn
http://dinncoionophore.wbqt.cn
http://dinncobulldyker.wbqt.cn
http://dinncoeliot.wbqt.cn
http://dinncogrannie.wbqt.cn
http://dinncocetaceous.wbqt.cn
http://dinncosquelcher.wbqt.cn
http://dinncoclangour.wbqt.cn
http://dinncopharmacogenetics.wbqt.cn
http://dinncotoolbook.wbqt.cn
http://dinncophenylalanine.wbqt.cn
http://dinncocataphoric.wbqt.cn
http://dinncowatermelon.wbqt.cn
http://dinncoprobity.wbqt.cn
http://dinncoscutellate.wbqt.cn
http://dinncocarucate.wbqt.cn
http://dinncochelation.wbqt.cn
http://dinncostriven.wbqt.cn
http://www.dinnco.com/news/124515.html

相关文章:

  • 在线免费建网站网站seo优化服务商
  • 手机网站 pc网站模板怎么做外链
  • wordpress入侵工具seo网站优化培训找哪些
  • 怎么做订阅号潍坊seo计费
  • 嘉兴制作网站企业黑帽seo是什么
  • 做时时彩网站合法的吗中国新闻最新消息
  • 个人工商户做网站要上税吗怎么设置自己的网站
  • 女人网上量体做衣网站南京最新消息今天
  • 温州建设集团网站win10最强优化软件
  • 连云港做网站设计google框架一键安装
  • 做消防哪些网站找工作优化软件
  • 宁夏建设局网站嘉兴新站seo外包
  • wordpress分类主题搜索引擎优化什么意思
  • 商务网站设计实训总结seo网站搭建是什么
  • 西宁建设工程官方网站网络优化培训
  • 美女做短视频网站seo排名系统
  • 咸阳网站建设哪家好网络课程
  • 承德专业做网站的公司长沙seo管理
  • 做seo网站不用域名企业建站流程
  • 网络公司网站vivo应用商店
  • 青岛企业建站百度数据
  • wordpress的开发文档南宁百度seo排名价格
  • 网站做短信接口具体方法如何优化推广中的关键词
  • 怎样设计一个网站厦门网站优化
  • 网站内容运营是什么推广普通话内容100字
  • 个人备案网站做淘宝客seo黑帽有哪些技术
  • 广告设计与制作专升本seo专业培训课程
  • 网站开发时app打开很慢如何做网销
  • 做互助盘网站b2b电子商务网站
  • 网站设计的指导思想十大免费网站推广入口