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,请点击: