Spire.Office for Java v3.4.0已正式发布。该版本新增加了一些功能,例如Spire.PDF、Spire.Presentation、Spire.XLS均有新功能发布。
你在寻找支持在Java中用编程方法处理各类格式文档的API吗巧,Java版企业级文档管理组合套包Spire.Office 2020全新上线!Word、Excel、PPT、PDF、条形码等格式一 打尽。
目前,
新功能及问题修复详情,请参阅如下内容。
Spire.PDF for Java()
优化:
- 优化了转换PDF到Word的时间。
新功能:
-
支持在签名PDF页面时自定义签名 图片/名称/信息 的宽度。
signature.setCustomSignPosition(true).signature.setCustomSignImagePosition(x,y,width,height).signature.setCustomSignNamePosition(x,y,width,height)signature.setCustomSignDetailPosition(x,y,width,height).
-
setAuthor(String value);setSubject(String value);setCreationDate(Date value);setModifiedDate(Date value);
-
支持展开指定书签。
setExpandBookmark(boolean value)
-
支持获取RadioButton域的样式。
PdfRadioButtonListFieldWidget radio = (PdfRadioButtonListFieldWidget)field;//获取按钮样式PdfCheckBoxStyle buttonStyle = radio.getButtonStyle();
-
支持创建PDF启动操作。
PdfDocument doc = new PdfDocument();PdfPageBase page = doc.getPages().add();//Create a PDF Launch ActionPdfLaunchAction launchAction = new PdfLaunchAction(inputFile);//Create a PDF Action Annotation with the PDF Launch ActionString text = "Click here to open file";PdfTrueTypeFont font = new PdfTrueTypeFont(new Font("Arial",0, 13));Rectangle2D rect = new Rectangle2D.Float(50, 50, 230, 15);page.getCanvas().drawString(text, font, PdfBrushes.getForestGreen(), rect);PdfActionAnnotation annotation = new PdfActionAnnotation(rect, launchAction);//Add the PDF Action Annotation to pagepage.getAnnotationsWidget().add(annotation);//Save the documentdoc.saveToFile(outputFile);
-
实现提取高亮文本和颜色的功能。
PdfDocument doc = new PdfDocument();//Load a pdf filedoc.loadFromFile(inputFile);FileWriter fw=new FileWriter(outputFile,true);BufferedWriter bw=new BufferedWriter(fw);bw.write("Extracted hightlighted text:"+"n");PdfPageBase page = doc.getPages().get(0);for (int i = 0; i < page.getAnnotationsWidget().getCount(); i++) { if (page.getAnnotationsWidget().get(i) instanceof PdfTextMarkupAnnotationWidget) { PdfTextMarkupAnnotationWidget textMarkupAnnotation = (PdfTextMarkupAnnotationWidget)page.getAnnotationsWidget().get(i); //Get the highlighted text bw.write(page.extractText(textMarkupAnnotation.getBounds())); //Get the highlighted color PdfRGBColor color = textMarkupAnnotation.getTextMarkupColor(); bw.write("Color="+(color.getR() & 0XFF) +","+(color.getG() & 0XFF)+","+(color.getB() & 0XFF)+"n"); } }
-
支持获取目录内容的目标。
PdfDocument pdf = new PdfDocument(folder + "testTOC.pdf");//Get the first pagePdfPageBase page = pdf.getPages().get(0);//Get the annotation collectionPdfDocumentLinkAnnotationWidget link;PdfDestination destination;PdfAnnotationCollection annotations = page.getAnnotationsWidget();for (int i = 0; i < annotations.getCount(); i++) { if (annotations.get(i) instanceof PdfDocumentLinkAnnotationWidget) { link = (PdfDocumentLinkAnnotationWidget)annotations.get(i); destination =link.getDestination(); int pageIndex = destination.getPageNumber(); System.out.println("page Index of "+link.getName()+":"+pageIndex); Point2D location = destination.getLocation(); System.out.println("location: "+location.getX()+","+location.getY()); } }
-
支持设置画笔的虚实线格式。
//Create a penPdfPen pen = new PdfPen(new PdfRGBColor(Color.red), 3f);//Set dash stylepen.setDashStyle(PdfDashStyle.Dash);
-
支持嵌入3D文件。
String inputFile = "data/CreatePdf3DAnnotation.u3d";String outputFile = "output/CreatePdf3DAnnotation.pdf";//Create a Pdf document.PdfDocument pdf = new PdfDocument();//Add a new page.PdfPageBase page = pdf.getPages().add();//Draw a rectangle on the page to define the canvas area for the 3D file.Rectangle rt = new Rectangle(0, 80, 200, 200);//Initialize a new object of Pdf3DAnnotation, load the .u3d file as 3D annotation.Pdf3DAnnotation annotation = new Pdf3DAnnotation(rt, inputFile);annotation.setActivation(new Pdf3DActivation());annotation.getActivation().setActivationMode(Pdf3DActivationMode.Page_Open);Pdf3DView View = new Pdf3DView();View.setBackground(new Pdf3DBackground(new PdfRGBColor(128,0,128)));View.setViewNodeName("3DAnnotation");View.setRenderMode(new Pdf3DRendermode(Pdf3DRenderStyle.Solid));View.setInternalName("3DAnnotation");View.setLightingScheme(new Pdf3DLighting());View.getLightingScheme().setStyle(Pdf3DLightingStyle.Day);//Set the 3D view mode for the annotation.annotation.getViews().add(View);//Add the annotation to Pdf.page.getAnnotationsWidget().add(annotation);//Save the documentpdf.saveToFile(outputFile);
-
支持嵌入声音文件。
String inputFile = "data/EmbedSoundFile.pdf";String inputFile_1 = "data/Music.wav";String outputFile = "output/EmbedSoundFile.pdf";//create a pdf documentPdfDocument doc = new PdfDocument();//load file from diskdoc.loadFromFile(inputFile);//get the first pagePdfPageBase page = doc.getPages().get(0);//create a sound actionPdfSoundAction soundAction = new PdfSoundAction(inputFile_1);soundAction.getSound().setBits(16);//8时为杂音soundAction.getSound().setChannels(PdfSoundChannels.Stereo);soundAction.getSound().setEncoding(PdfSoundEncoding.Signed);soundAction.setVolume(0.8f);soundAction.setRepeat(true);//set the sound action to be executed when the PDF document is openeddoc.setAfterOpenAction(soundAction);//save the documentdoc.saveToFile(outputFile);
-
支持设置页面标签的顺序。
PdfPageBase page = pdf.getPages().get(0);page.SetTabOrder(TabOrder.Structure);
问题修复:
- 修复了用图片签名PDF后,图片被拉伸的问题。
- 修复了在添加注释后程序抛异常“NullPointerException”的问题。
- 修复了绘制包含按钮域且按钮域填充了图片的PDF页面到新页面,新页面的按钮域图片变小的问题。
Spire.Presentation for Java()
新功能:
-
支持转换一个GroupShape到图片。
Presentation ppt = new Presentation();ppt.loadFromFile(input);for (int i = 0; i < ppt.getSlides().get(0).getShapes().getCount(); i++){ String fileName = outputPath + "shapeToImage_"+i+".png"; BufferedImage image = ppt.getSlides().get(0).getShapes().saveAsImage(i); ImageIO.write(image, "PNG", new File(fileName)); }
-
支持设置、获取幻灯片标题。
ISlide slide1 = ppt.getSlides().get(0);slide1.getTitle();slide1.setTitle("new title");
-
支持设置文本高亮选项
TextHighLightingOptions options = new TextHighLightingOptions();options.setWholeWordsOnly(true);options.setCaseSensitive(true);shape.getTextFrame().HighLightText("Spire", Color.yellow, options);
-
支持设置动画播放重复类型。
nimationEffectCollection animations = slide.getTimeline().getMainSequence(); animations.get(0).getTiming().setAnimationRepeatType(AnimationRepeatType.UtilEndOfSlide);
-
支持转换形状到图片时设置分辨率的功能。
Presentation ppt = new Presentation();ppt.loadFromFile(input);for (int i = 0; i < ppt.getSlides().get(0).getShapes().getCount(); i++){ String fileName = outputPath + "shapeToImage_demo"+i+".png"; BufferedImage image = ppt.getSlides().get(0).getShapes().saveAsImage(i,300,300); ImageIO.write(image, "PNG", new File(fileName)); }
-
支持获取文本在形状内位置的功能。
Presentation ppt = new Presentation();ppt.loadFromFile(inputFile);IAutoShape shape = (IAutoShape)ppt.getSlides().get(0).getShapes().get(0);Point2D location =shape.getTextFrame().getTextLocation();String concent = "text在第一张幻灯片中Shape中的坐标: x= " + (location.getX() - shape.getLeft()) + " y= " + (location.getY() - shape.getTop());System.out.println(concent);
问题修复:
- 修复了转换形状到图片部分内容丢失的问题。
- 修复了转换形状到图片程序抛NullPointerException异常。
- 修复了转换形状到图片程序抛Argument width[318] or height[0] cannot be less or equal to zero。
- 修复了设置数据标签的旋转角度后结果文档打开失败的问题。
- 修复了加载ODP文档抛Unsupported file format。
- 修复了转换形状到图片公式内容不正确的问题。
- 修复了失败的设置图表系列的间隙宽度的问题。
- 修复了转换PPT到PDF/Word时,图表不正确的问题。
- 修复了添加Html内容失败的问题。
- 修复了设置DOUGHNUT图表的图例字体以及颜色失败的问题。
- 修复了添加html后h1标签加粗样式丢失的问题。
- 修复了创建图表保存文档失败的问题。
Spire.Doc for Java()
新功能:
-
支持了设置对角线表格边框。
Document doc = new Document();Section section = doc.addSection();Table oTable = section.addTable(true);section.addParagraph();oTable.resetCells(10, 3);oTable.getTableFormat().getPaddings().setTop(10);oTable.getTableFormat().getPaddings().setBottom(10);oTable.getTableFormat().setHorizontalAlignment(RowAlignment.Center); oTable.getLastCell().getCellFormat().getBorders().getDiagonalUp().setBorderType(BorderStyle.Single); oTable.getFirstRow().getCells().get(0).getCellFormat().getBorders().getDiagonalDown().setBorderType(BorderStyle.Double);doc.saveToFile(outputFile);
-
支持设置装订线的功能。
Section section = document.getSections().get(0);section.getPageSetup().setGutter(100f);
-
支持设置表格单元格的对角线边框。
table.get(0,0).getCellFormat().getBorders().getDiagonalUp().setBorderType(BorderStyle.Single);table.get(0,0).getCellFormat().getBorders().getDiagonalUp().setColor(Color.blue);table.get(0,0).getCellFormat().getBorders().getDiagonalUp().setLineWidth(0.5f); table.get(0,0).getCellFormat().getBorders().getDiagonalDown().setBorderType(BorderStyle.Single);table.get(0,0).getCellFormat().getBorders().getDiagonalDown().setColor(Color.blue);table.get(0,0).getCellFormat().getBorders().getDiagonalDown().setLineWidth(0.5f);
问题修复:
- 修复了当一个项目中同时使用spire.office.jar和crimson.jar时程序抛出异常” java.lang.AbstractMethodError”。
- 修复了更新内容目录后,目录内容不正确的问题。
- 修复了Word to SVG 程序抛异常StackOverflowError。
- 修复了插入的PDF OLE对象不能打开。
- 修复了Word转PDF内容不正确。
- 修复了Word转pdf,抛异常java.lang.NullPointerException。
- 修复了Word转pdf,抛异常java.lang.StackOverflowError。
- 修复了加载文档抛异常java.lang.IllegalStateException。
- 修复了移除分页符保存文档失败的问题。
- 修复了加载文档抛”NullPointerException”的问题。
- 修复了清除分节符后保存文档抛“ClassCastException”的问题。
- 修复了加载文档抛异常”Cannot remove because there is no parent”的问题。
- 修复了加载文档抛异常”No have this value 1062″的问题。
- 修复了在转换XML到Word后,标签无法被识别为分页的问题。
- 修复了加载文档抛异常”Value was either too large or too small for Int32″的问题。
- 修复了加载文档抛异常”This is not a structured storage file”的问题。
- 修复了转换Word到PDF抛“IndexOutOfBoundsException”的问题。
- 修复了加载文档抛异常”com.spire.doc.documents.VerticalOrigin cannot be cast to com.spire.doc.verticalRelation”的问题。
- 修复了清除分节符后保存文档抛“The argument cannot be null or empty string”的问题。
- 修复了清除段落列表格式后保存文档抛“NullPointerException”的问题。
- 修复了清除分节符后保存文档抛“Unrecognized image type”的问题。
Spire.XLS for Java()
新功能:
-
支持拷贝单元格样式。
srcRange.copy(destRange,true,true);公布GroupByTape 和ExpandCollapseFlags枚举类型。worksheet.getRange().get("A1:C1").expandGroup(GroupByType.ByRows,ExpandCollapseFlags.ExpandParent);
-
支持不显示零。
worksheet.isDisplayZeros(false);
-
支持移除DataValidation。
workbook.getWorksheets().get(0).getDVTable().remove(rectangles);
-
支持设置PrintError为NA。
pageSetup.setPrintErrors(PrintErrorsType.NA);
-
支持添加单选按钮,拷贝组合框,线条以及单选按钮。
//添加单选按钮worksheet.getRadioButtons().add(5,5,20,20);//拷贝线条worksheet.getTypedLines().addCopy(line);//拷贝单选按钮worksheet.getTypedRadioButtons().addCopy(button);//拷贝组合框worksheet.getTypedComboBoxes().addCopy(combobox);
-
支持转换sheet到CSV仅保留过滤后的数据。
worksheet.saveToFile("CsvFilePath", ";", false);
问题修复:
- 修复了查找数字失败的问题。
- 修复了数组列表在insertArrayList方法中不匹配的问题。
- 修复了获取链接类型不正确的问题。
- 修复了字体无法被正确嵌入的问题。
- 修复了添加的箭头样式不正确的问题。
- 修复了保护sheet不生效的问题。
- 修复了设置textbox的内边距不生效的问题。
- 修复了应用markerdesigner程序抛异常的问题。
- 修复了添加单元格名称不成功的问题。
- 修复了获取文档属性抛异常的问题。
- 修复了条件格式的边框颜色显示不正确的问题。
- 修复了添加DataTable到MarkerDesigner,程序抛异常的问题。
- 修复了添加背景图到透视表,结果文档打开提示错误的问题。
- 修复了转换Excel到HTML,程序抛异常“ArrayIndexOutOfBoundsException”的问题。
- 修复了先设置单元格水平居中对齐,再设置垂直居中不生效的问题。
- 修复了在MAC环境转换Excel到PDF抛“NullPointerException”的问题。
还想要更多吗可以点击阅读【2019 · E-iceblue最新资源整合】,查找需要的教程资源。如果您有任何疑问或需求,请随时联系客服,我们很高兴为您提供查询和咨询。
标签:
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!