Spire.PDF for Java 3.4.2 现已正式发布。该版本支持 嵌入3D文件 和声音文件,也支持设置画笔的虚实线格式。除此之外,该版本还成功修复了一些在删除图片和获取PDF文档缩放比例时出现的问题。新功能及问题修复详情,请查阅以下内容。
新功能:
- 支持设置画笔的虚实线格式。
//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); 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);
问题修复:
- 修复了删除图片失败的问题。
- 修复了获取PDF文档缩放比例失败的问题。
获取Spire.PDF for Java 3.4.2,请点击: