帮忙确认一下。
1、aspose slides支持水印吗
2、图表(如折线图柱形图)支持双Y轴吗。
以上如支持请提供示例
编程语言是Java,谢谢~~~~~~
Aspose.Slides for Java 支持水印。您可以添加文本水印和图像水印。以下代码示例展示了如何添加文本水印:
String filePath = "sample.pptx";
String watermarkText = "Confidential";
float watermarkAngle = -45;
float watermarkFontHeight = 52;
Color watermarkColor = new Color(200, 200, 200, 150);
Presentation presentation = new Presentation(filePath);
Dimension2D slideSize = presentation.getSlideSize().getSize();
float x = 0;
float y = 0;
float width = (float) slideSize.getWidth();
float height = (float) slideSize.getHeight();
for (ISlide slide : presentation.getSlides()) {
IAutoShape watermarkShape = slide.getShapes().addAutoShape(ShapeType.Rectangle, x, y, width, height);
watermarkShape.getFillFormat().setFillType(FillType.NoFill);
watermarkShape.getLineFormat().getFillFormat().setFillType(FillType.NoFill);
watermarkShape.setRotation(watermarkAngle);
ITextFrame watermarkTextFrame = watermarkShape.addTextFrame(watermarkText);
IPortion watermarkTextPortion = watermarkTextFrame.getParagraphs().get_Item(0).getPortions().get_Item(0);
watermarkTextPortion.getPortionFormat().setFontHeight(watermarkFontHeight);
IFillFormat fillFormat = watermarkTextPortion.getPortionFormat().getFillFormat();
fillFormat.setFillType(FillType.Solid);
fillFormat.getSolidFillColor().setColor(watermarkColor);
watermarkShape.getAutoShapeLock().setSelectLocked(true);
watermarkShape.getAutoShapeLock().setSizeLocked(true);
watermarkShape.getAutoShapeLock().setTextLocked(true);
watermarkShape.getAutoShapeLock().setPositionLocked(true);
watermarkShape.getAutoShapeLock().setGroupingLocked(true);
}
presentation.save("output.pptx", SaveFormat.Pptx);
presentation.dispose();
结果: output.zip (25.2 KB)
详细信息: Watermark|Aspose.Slides Documentation
Aspose.Slides for Java 可以创建具有双轴的图表。以下代码示例向您展示了如何创建具有双轴的组合图表。
Presentation pres = new Presentation();
ISlide slide = pres.getSlides().get_Item(0);
IChart chart = createStackedColumnChart(slide);
addLineChart(chart);
applyStyles(chart);
pres.save("output.pptx", SaveFormat.Pptx);
pres.dispose();
private static IChart createStackedColumnChart(ISlide slide)
{
IChart chart = slide.getShapes().addChart(ChartType.StackedColumn, 50, 50, 600, 400);
chart.getChartData().getSeries().clear();
chart.getChartData().getCategories().clear();
IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
final int worksheetIndex = 0;
chart.getChartData().getCategories().add(workbook.getCell(worksheetIndex, 1, 0, "Category 1"));
chart.getChartData().getCategories().add(workbook.getCell(worksheetIndex, 2, 0, "Category 2"));
chart.getChartData().getCategories().add(workbook.getCell(worksheetIndex, 3, 0, "Category 3"));
chart.getChartData().getCategories().add(workbook.getCell(worksheetIndex, 4, 0, "Category 4"));
IChartSeries series = chart.getChartData().getSeries().add(workbook.getCell(worksheetIndex, 0, 1, "Series 1"), ChartType.StackedColumn);
series.getDataPoints().addDataPointForBarSeries(workbook.getCell(worksheetIndex, 1, 1, 2.4));
series.getDataPoints().addDataPointForBarSeries(workbook.getCell(worksheetIndex, 2, 1, 4.4));
series.getDataPoints().addDataPointForBarSeries(workbook.getCell(worksheetIndex, 3, 1, 1.8));
series.getDataPoints().addDataPointForBarSeries(workbook.getCell(worksheetIndex, 4, 1, 2.8));
series.getParentSeriesGroup().setOverlap((byte)100);
series.getParentSeriesGroup().setGapWidth(219);
series.getFormat().getFill().setFillType(FillType.Solid);
series.getFormat().getFill().getSolidFillColor().setColor(new Color(233, 113, 50));
return chart;
}
private static void addLineChart(IChart chart)
{
IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
final int worksheetIndex = 0;
IChartSeries series = chart.getChartData().getSeries().add(workbook.getCell(worksheetIndex, 0, 3, "Series 2"), ChartType.Line);
series.getDataPoints().addDataPointForLineSeries(workbook.getCell(worksheetIndex, 1, 2, 2));
series.getDataPoints().addDataPointForLineSeries(workbook.getCell(worksheetIndex, 2, 2, 2));
series.getDataPoints().addDataPointForLineSeries(workbook.getCell(worksheetIndex, 3, 2, 3));
series.getDataPoints().addDataPointForLineSeries(workbook.getCell(worksheetIndex, 4, 2, 5));
series.setPlotOnSecondAxis(true);
series.getFormat().getLine().getFillFormat().setFillType(FillType.Solid);
series.getFormat().getLine().getFillFormat().getSolidFillColor().setColor(new Color(72, 172, 83));
chart.getAxes().getSecondaryVerticalAxis().setTickLabelPosition(TickLabelPositionType.High);
}
private static void applyStyles(IChart chart)
{
//Chart title
chart.setTitle(true);
chart.getChartTitle().setOverlay(false);
ITextFrame chartTitle = chart.getChartTitle().addTextFrameForOverriding("Chart Title");
IPortionFormat portionFormat = chartTitle.getParagraphs().get_Item(0).getParagraphFormat().getDefaultPortionFormat();
portionFormat.setFontHeight(18);
portionFormat.setFontBold(NullableBool.False);
portionFormat.setLatinFont(new FontData("Aptos"));
portionFormat.getFillFormat().setFillType(FillType.Solid);
portionFormat.getFillFormat().getSolidFillColor().setColor(new Color(89, 89,89));
//Axis styles
chart.getAxes().getHorizontalAxis().getFormat().getLine().getFillFormat().setFillType(FillType.NoFill);
chart.getAxes().getHorizontalAxis().getMinorGridLinesFormat().getLine().getFillFormat().setFillType(FillType.NoFill);
chart.getAxes().getHorizontalAxis().getMajorGridLinesFormat().getLine().getFillFormat().setFillType(FillType.NoFill);
chart.getAxes().getHorizontalAxis().setMajorTickMark(TickMarkType.None);
chart.getAxes().getHorizontalAxis().setAxisBetweenCategories(true);
chart.getAxes().getSecondaryHorizontalAxis().setVisible(false);
chart.getAxes().getSecondaryHorizontalAxis().getMinorGridLinesFormat().getLine().getFillFormat().setFillType(FillType.NoFill);
chart.getAxes().getSecondaryHorizontalAxis().getMajorGridLinesFormat().getLine().getFillFormat().setFillType(FillType.NoFill);
chart.getAxes().getVerticalAxis().getFormat().getLine().getFillFormat().setFillType(FillType.NoFill);
chart.getAxes().getVerticalAxis().setMajorTickMark(TickMarkType.None);
chart.getAxes().getVerticalAxis().getMinorGridLinesFormat().getLine().getFillFormat().setFillType(FillType.NoFill);
chart.getAxes().getVerticalAxis().getMajorGridLinesFormat().getLine().getFillFormat().setFillType(FillType.Solid);
chart.getAxes().getVerticalAxis().getMajorGridLinesFormat().getLine().getFillFormat().getSolidFillColor().setColor(new Color(217, 217, 217));
chart.getAxes().getSecondaryVerticalAxis().getFormat().getLine().getFillFormat().setFillType(FillType.NoFill);
chart.getAxes().getSecondaryVerticalAxis().getMinorGridLinesFormat().getLine().getFillFormat().setFillType(FillType.NoFill);
chart.getAxes().getSecondaryVerticalAxis().getMajorGridLinesFormat().getLine().getFillFormat().setFillType(FillType.NoFill);
setTextFormatForAxis(chart.getAxes().getHorizontalAxis());
setTextFormatForAxis(chart.getAxes().getVerticalAxis());
setTextFormatForAxis(chart.getAxes().getSecondaryVerticalAxis());
//Series styles
chart.getLegend().getTextFormat().getPortionFormat().setFontHeight(12);
chart.getLegend().getTextFormat().getPortionFormat().setLatinFont(new FontData("Aptos"));
chart.getLegend().getTextFormat().getPortionFormat().getFillFormat().setFillType(FillType.Solid);
chart.getLegend().getTextFormat().getPortionFormat().getFillFormat().getSolidFillColor().setColor(new Color(89, 89,89));
chart.getLegend().setPosition(LegendPositionType.Bottom);
}
private static void setTextFormatForAxis(IAxis value)
{
value.getTextFormat().getPortionFormat().setFontHeight(12);
value.getTextFormat().getPortionFormat().setLatinFont(new FontData("Aptos"));
value.getTextFormat().getPortionFormat().getFillFormat().setFillType(FillType.Solid);
value.getTextFormat().getPortionFormat().getFillFormat().getSolidFillColor().setColor(new Color(89, 89,89));
}
结果: output2.zip (32.1 KB)
详细信息: PowerPoint Charts - How to Create and Modify a Chart in C#|Aspose.Slides Documentation
使用aspose slides 根据ppt上设置的图表样式(如:两个柱形一个折线组合图,双Y轴),生成后的效果为(单Y轴,都为柱形图)与之前的图表样式不一致,代码已提供,产品是否支持,若支持该如何实现。
双Y轴.zip (775.2 KB)
就是根据你们发的代码操作,PPT模版定义的图表格式是:2个柱形一个折线组合图,双Y轴。但是转换之后变成了只有柱状图了。
设置的模版5d8d921958fd0c70e3bfcf01f620ce3.png (36.2 KB)
转换后:
935ecaab80e43595e6494713baeac72.png (3.6 KB)
你们可以按照之前的压缩文档里的代码执行看看
插入图片方式,还是不行哦~
我重现了问题并查看了您的代码。您删除了所有图表数据,因此相应的数据显示样式也消失了。
我们在内部问题跟踪系统中开了以下新工单,并将根据Free Support Policies中提到的条款提供修复。
Issue ID(s): SLIDESJAVA-39524
你可以通过访问 Paid Support Services 获得优先支持,并直接联系我们的付费支持管理团队。
把数据删除的逻辑去掉,以及完善数据。图表显示还是不对
b2fb9c2ee86d2229d5f12e280f54899.png (23.2 KB)
5a8dffa624bad68eaf966552e62ba6e.png (119.6 KB)
双Y轴的图表基于我提供的代码那种场景:是基于ppt上配置好图表显示格式,通过aspose slides生成的,请问能提供正确的示例吗?
@SalesDhorde,
关于问题SLIDESJAVA-39524,很遗憾,无法创建完全不可编辑的形状。但您可以使用母版幻灯片来隐藏水印形状,就像微软本身推荐的那样: https://www.youtube.com/watch?v=hXyLO31Bnqk
如果我理解正确,您希望使用 “demo.pptx” 中的图表,并以相同的风格创建另一个图表。如果是这样,请分享包含要创建的图表的演示文稿。