原創(chuàng)|產(chǎn)品更新|編輯:李顯亮|2020-04-30 11:46:57.740|閱讀 624 次
概述:Spire.Office for Java v3.4.0已正式發(fā)布。該版本新增加了一些功能,例如Spire.PDF、Spire.Presentation、Spire.XLS均有新功能發(fā)布。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
你在尋找支持在Java中用編程方法處理各類格式文檔的API嗎?好巧,Java版企業(yè)級(jí)文檔管理組合套包Spire.Office 2020全新上線!Word、Excel、PPT、PDF、條形碼等格式一網(wǎng)打盡。
目前,Spire.Office for Java 迎來了v3.4.0版的更新。該版本中,Spire.PDF支持在簽名時(shí)自定義圖片/名稱/信息的寬度,支持給PdfAnnotation設(shè)置作者/主題/創(chuàng)建日期/修改日期屬性,支持創(chuàng)建PDF啟動(dòng)操作,支持提取高亮文本和顏色,支持嵌入3D文件和聲音文件;Spire.Presentation支持轉(zhuǎn)換一個(gè)GroupShape到圖片,支持設(shè)置/獲取幻燈片標(biāo)題,支持設(shè)置動(dòng)畫播放重復(fù)類型;Spire.Doc支持設(shè)置對(duì)角線表格邊框,支持設(shè)置裝訂線;Spire.XLS支持拷貝單元格樣式,支持移除DataValidation。此外,本次更新還修復(fù)了在加載、轉(zhuǎn)換和操作PDF、PowerPoint、Word、Excel文檔時(shí)出現(xiàn)的一些問題。點(diǎn)擊下方按鈕即可下載試用↓↓↓
免費(fèi)下載Spire.Office for Java v3.4.0
新功能及問題修復(fù)詳情,請(qǐng)參閱如下內(nèi)容。
優(yōu)化:
新功能:
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時(shí)為雜音 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);
問題修復(fù):
新功能:
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中的坐標(biāo): x= " + (location.getX() - shape.getLeft()) + " y= " + (location.getY() - shape.getTop()); System.out.println(concent);
問題修復(fù):
新功能:
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);
問題修復(fù):
新功能:
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);
問題修復(fù):
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn