|
@@ -666,7 +666,21 @@ public class GameEventServiceImpl implements IGameEventService {
|
|
|
backgroundImageBytes = backgroundImage.getBytes();
|
|
|
|
|
|
if (logo != null && !logo.isEmpty()) {
|
|
|
+ // 验证logo文件类型
|
|
|
+ String contentType = logo.getContentType();
|
|
|
+ if (contentType == null || !contentType.startsWith("image/")) {
|
|
|
+ throw new IllegalArgumentException("Logo文件必须是图片格式");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 验证logo文件大小(例如限制为2MB)
|
|
|
+ // if (logo.getSize() > 2 * 1024 * 1024) {
|
|
|
+ // throw new IllegalArgumentException("Logo文件大小不能超过2MB");
|
|
|
+ // }
|
|
|
+
|
|
|
logoImageBytes = logo.getBytes();
|
|
|
+// log.info("Logo图片上传成功,大小: {} bytes", logoImageBytes.length);
|
|
|
+ } else {
|
|
|
+ log.info("未上传Logo图片,将跳过Logo处理");
|
|
|
}
|
|
|
} catch (IOException e) {
|
|
|
throw new RuntimeException("读取上传文件失败", e);
|
|
@@ -717,12 +731,17 @@ public class GameEventServiceImpl implements IGameEventService {
|
|
|
|
|
|
// 添加 Logo(如果存在)
|
|
|
if (finalLogoImageBytes != null && logoX != null && logoY != null) {
|
|
|
- Image img = Image.getInstance(finalLogoImageBytes);
|
|
|
- img.scaleToFit(80, 80);
|
|
|
- float logoPositionX = logoX.floatValue();
|
|
|
- float logoPositionY = logoY.floatValue();
|
|
|
- img.setAbsolutePosition(logoPositionX, logoPositionY);
|
|
|
- cb.addImage(img);
|
|
|
+ try {
|
|
|
+ Image img = Image.getInstance(finalLogoImageBytes);
|
|
|
+ img.scaleToFit(80, 80);
|
|
|
+ float logoPositionX = logoX.floatValue();
|
|
|
+ float logoPositionY = logoY.floatValue();
|
|
|
+ img.setAbsolutePosition(logoPositionX, logoPositionY);
|
|
|
+ cb.addImage(img);
|
|
|
+// log.debug("成功添加Logo到PDF");
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.warn("添加Logo到PDF失败,跳过Logo处理: {}", e.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 添加号码(居中)
|