原创|产品更新|编辑:李显亮|2020-04-30 11:46:57.740|阅读 589 次
概述:Spire.Office for Java v3.4.0已正式发布。该版本新增加了一些功能,例如Spire.PDF、Spire.Presentation、Spire.XLS均有新功能发布。
# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>
你在寻找支持在Java中用编程方法处理各类格式文档的API吗?好巧,Java版企业级文档管理组合套包Spire.Office 2020全新上线!Word、Excel、PPT、PDF、条形码等格式一网打尽。
目前,Spire.Office for Java 迎来了v3.4.0版的更新。该版本中,Spire.PDF支持在签名时自定义图片/名称/信息的宽度,支持给PdfAnnotation设置作者/主题/创建日期/修改日期属性,支持创建PDF启动操作,支持提取高亮文本和颜色,支持嵌入3D文件和声音文件;Spire.Presentation支持转换一个GroupShape到图片,支持设置/获取幻灯片标题,支持设置动画播放重复类型;Spire.Doc支持设置对角线表格边框,支持设置装订线;Spire.XLS支持拷贝单元格样式,支持移除DataValidation。此外,本次更新还修复了在加载、转换和操作PDF、PowerPoint、Word、Excel文档时出现的一些问题。点击下方按钮即可下载试用↓↓↓
免费下载Spire.Office for Java v3.4.0
新功能及问题修复详情,请参阅如下内容。
优化:
新功能:
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)
PdfRadioButtonListFieldWidget radio = (PdfRadioButtonListFieldWidget)field; //获取按钮样式 PdfCheckBoxStyle buttonStyle = radio.getButtonStyle();
PdfDocument doc = new PdfDocument(); PdfPageBase page = doc.getPages().add(); //Create a PDF Launch Action PdfLaunchAction launchAction = new PdfLaunchAction(inputFile); //Create a PDF Action Annotation with the PDF Launch Action String 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 page page.getAnnotationsWidget().add(annotation); //Save the document doc.saveToFile(outputFile);
PdfDocument doc = new PdfDocument(); //Load a pdf file doc.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 page PdfPageBase page = pdf.getPages().get(0); //Get the annotation collection PdfDocumentLinkAnnotationWidget 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 pen PdfPen pen = new PdfPen(new PdfRGBColor(Color.red), 3f); //Set dash style pen.setDashStyle(PdfDashStyle.Dash);
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 document pdf.saveToFile(outputFile);
String inputFile = "data/EmbedSoundFile.pdf"; String inputFile_1 = "data/Music.wav"; String outputFile = "output/EmbedSoundFile.pdf"; //create a pdf document PdfDocument doc = new PdfDocument(); //load file from disk doc.loadFromFile(inputFile); //get the first page PdfPageBase page = doc.getPages().get(0); //create a sound action PdfSoundAction 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 opened doc.setAfterOpenAction(soundAction); //save the document doc.saveToFile(outputFile);
PdfPageBase page = pdf.getPages().get(0); page.SetTabOrder(TabOrder.Structure);
问题修复:
新功能:
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);
问题修复:
新功能:
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);
问题修复:
新功能:
srcRange.copy(destRange,true,true); 公布GroupByTape 和ExpandCollapseFlags枚举类型。 worksheet.getRange().get("A1:C1").expandGroup(GroupByType.ByRows,ExpandCollapseFlags.ExpandParent);
worksheet.isDisplayZeros(false);
workbook.getWorksheets().get(0).getDVTable().remove(rectangles);
pageSetup.setPrintErrors(PrintErrorsType.NA);
//添加单选按钮 worksheet.getRadioButtons().add(5,5,20,20); //拷贝线条 worksheet.getTypedLines().addCopy(line); //拷贝单选按钮 worksheet.getTypedRadioButtons().addCopy(button); //拷贝组合框 worksheet.getTypedComboBoxes().addCopy(combobox);
worksheet.saveToFile("CsvFilePath", ";", false);
问题修复:
本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@pclwef.cn