mirror of
https://github.com/dataease/dataease.git
synced 2025-02-24 03:22:56 +08:00
refactor(X-Pack): 增加Excel水印单独控制逻辑 (#14455)
Co-authored-by: xuwei-fit2cloud <wei@fit2cloud.com>
This commit is contained in:
parent
1298bf7bd9
commit
9f602d49d6
@ -78,8 +78,9 @@ public class ExcelWatermarkUtils {
|
||||
}
|
||||
|
||||
public static byte[] createTextImage(String text, WatermarkContentDTO watermarkContent) {
|
||||
int width = watermarkContent.getWatermark_fontsize() * text.length() + 100;
|
||||
int height = watermarkContent.getWatermark_fontsize() + 50;
|
||||
double radians = Math.toRadians(15);// 15度偏转
|
||||
int width = watermarkContent.getWatermark_fontsize() * text.length();
|
||||
int height = (int) Math.round(watermarkContent.getWatermark_fontsize() + width * Math.sin(radians));
|
||||
int fontSize = watermarkContent.getWatermark_fontsize();
|
||||
Color baseColor = Color.decode(watermarkContent.getWatermark_color());
|
||||
|
||||
@ -95,10 +96,9 @@ public class ExcelWatermarkUtils {
|
||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
||||
// 设置字体
|
||||
g2d.setFont(new Font("Arial", Font.BOLD, fontSize));
|
||||
g2d.setFont(new Font("Arial", Font.PLAIN, fontSize));
|
||||
g2d.setColor(new Color(baseColor.getRed(), baseColor.getGreen(), baseColor.getBlue(), 50)); // 半透明颜色
|
||||
g2d.rotate(Math.toRadians(25), width / 2.0, height / 2.0); // 旋转文字
|
||||
|
||||
g2d.rotate(radians, width / 2.0, height / 2.0); // 旋转文字
|
||||
// 绘制文字
|
||||
FontMetrics fontMetrics = g2d.getFontMetrics();
|
||||
int textWidth = fontMetrics.stringWidth(text);
|
||||
|
@ -804,7 +804,7 @@ public class ExportCenterManage implements BaseExportApi {
|
||||
public void addWatermarkTools(Workbook wb){
|
||||
VisualizationWatermark watermark = watermarkMapper.selectById("system_default");
|
||||
WatermarkContentDTO watermarkContent = JsonUtil.parseObject(watermark.getSettingContent(), WatermarkContentDTO.class);
|
||||
if (watermarkContent.getExcelEnable()) {
|
||||
if (watermarkContent.getEnable() && watermarkContent.getExcelEnable()) {
|
||||
UserFormVO userInfo = visualizationMapper.queryInnerUserInfo(AuthUtils.getUser().getUserId());
|
||||
// 在主逻辑中添加水印
|
||||
int watermarkPictureIdx = ExcelWatermarkUtils.addWatermarkImage(wb, watermarkContent,userInfo); // 生成水印图片并获取 ID
|
||||
|
@ -3945,6 +3945,7 @@ Scatter chart (bubble) chart: {a} (series name), {b} (data name), {c} (value arr
|
||||
watermark: {
|
||||
support_params: 'Currently supported parameters:',
|
||||
enable: 'Enable',
|
||||
excel_enable: 'Enable watermark for exporting data files',
|
||||
enable_panel_custom: ' Allow dashboards to turn on or off watermarks individually',
|
||||
content: 'Content',
|
||||
custom_content: 'Custom formula',
|
||||
|
@ -3843,6 +3843,7 @@ export default {
|
||||
watermark: {
|
||||
support_params: '目前支援的參數:',
|
||||
enable: '啟用水印',
|
||||
excel_enable: '啟用數據文件導出水印',
|
||||
enable_panel_custom: '允許儀表板單獨開啟或關閉水印',
|
||||
content: '浮水印內容',
|
||||
custom_content: '自訂公式',
|
||||
|
@ -3847,6 +3847,7 @@ export default {
|
||||
watermark: {
|
||||
support_params: '当前支持的参数:',
|
||||
enable: '启用水印',
|
||||
excel_enable: '导出数据文件开启水印',
|
||||
enable_panel_custom: '允许仪表板单独打开或者关闭水印',
|
||||
content: '水印内容',
|
||||
custom_content: '自定义公式',
|
||||
|
2
de-xpack
2
de-xpack
@ -1 +1 @@
|
||||
Subproject commit cefee13df7d1d8cbf41adf8e65460d126f91b0f4
|
||||
Subproject commit 0e19755eee5a9961e27e4a0301a8f2b095cfd47c
|
Loading…
Reference in New Issue
Block a user