Skip to content

Commit 25aa9ae

Browse files
author
pavel.terechshenko
committed
up license
1 parent 3a2c8b9 commit 25aa9ae

30 files changed

+1149
-23
lines changed

Aspose.HTML-for-Java.Start/src/main/java/com/aspose/html/samples/start_application/AsposeHtmlApplication.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
package com.aspose.html.samples.start_application;
32

43
import java.io.OutputStreamWriter;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docker build -t alpine-java21 -f Docker.alpine.java.docker .
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docker run -p8080:9999 -p2222:22 --rm alpine-java21
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docker build -t docker.alpine.java.ms.google.fonts.docker-java21 -f Docker.alpine.java.ms.google.fonts.docker .
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docker run -p8080:9999 -p2222:22 --rm docker.alpine.java.ms.google.fonts.docker-java21

Aspose.HTML-for-Java.WebService-on-Docker/build.gradle

Lines changed: 44 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ plugins {
22
alias(libs.plugins.java)
33
alias(libs.plugins.spring.boot)
44
alias(libs.plugins.spring.dependency.management)
5-
// alias(libs.plugins.com.palantir.docker)
5+
// id 'org.graalvm.buildtools.native' version '0.11.0'
6+
id 'org.graalvm.buildtools.native' version '0.10.2'
67
}
78

89
repositories {
@@ -23,25 +24,51 @@ dependencies {
2324
testImplementation libs.spring.boot.starter.test
2425

2526
implementation libs.jsoup
27+
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
2628
}
2729

2830
test {
2931
useJUnitPlatform()
3032
}
3133

32-
//docker {
33-
// name "${project.group}/${project.name}:${project.version}"
34-
// files 'build/libs/your-app.jar'
35-
// buildArgs(['JAR_FILE': 'your-app.jar'])
36-
//}
37-
//
38-
//tasks.register('dockerBuild', Exec) {
39-
// commandLine 'docker', 'build', '-t', 'my-app:latest', '.'
40-
//}
41-
//
42-
//tasks.register('dockerRun', Exec) {
43-
// commandLine 'docker', 'run', '--rm', '-p', '8080:8080', 'my-app:latest'
44-
//}
45-
46-
// ./gradlew dockerBuild
47-
// ./gradlew dockerRun
34+
tasks.register('dockerBuild', Exec) {
35+
commandLine 'docker', 'build', '-t', 'alpine-java21','-f', 'Docker.alpine.java.docker', '.'
36+
}
37+
38+
tasks.register('dockerRun', Exec) {
39+
commandLine 'docker', 'run', '--rm', '-p', '8080:8080','-p', '2222:22', 'alpine-java21'
40+
}
41+
42+
tasks.register('dockerRun2', Exec) {
43+
commandLine 'docker', 'run', '--rm', '-p', '8080:8080','-p', '2222:22', 'alpine-java21'
44+
}
45+
46+
graalvmNative {
47+
toolchainDetection = false // полагаться на GRAALVM_HOME
48+
binaries {
49+
main {
50+
imageName = 'html-converter'
51+
debug = true
52+
verbose = true
53+
buildArgs.add('--initialize-at-build-time=com.aspose.html')
54+
buildArgs.add('-H:+ReportExceptionStackTraces')
55+
buildArgs.add('--enable-url-protocols=http,https')
56+
jvmArgs.add('-Dspring.native.remove-yaml-support=false')
57+
buildArgs.add("--verbose")
58+
}
59+
}
60+
}
61+
62+
configurations {
63+
developmentOnly
64+
runtimeClasspath {
65+
extendsFrom developmentOnly
66+
}
67+
}
68+
69+
java {
70+
toolchain {
71+
languageVersion = JavaLanguageVersion.of(21)
72+
vendor = JvmVendorSpec.GRAAL_VM
73+
}
74+
}

Aspose.HTML-for-Java.WebService-on-Docker/gradle.properties

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,11 @@
33
#JAVA_VERSION=11
44
#JAVA_VERSION=17
55
JAVA_VERSION=21
6-
#JAVA_VERSION=24
6+
#JAVA_VERSION=24
7+
8+
org.gradle.caching=false
9+
10+
# gradle.properties
11+
# ??????? ???????? ???? ? GraalVM JDK 21 ?? ??? ?? ?????, ??? ? ??????
12+
#org.gradle.java.installations.paths=D:\Users\notep\.jdks
13+
#org.gradle.java.installations.auto-download=false
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
plugins {
2+
id 'org.gradle.toolchains.foojay-resolver-convention' version '1.0.0'
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package com.aspose.html.sample.docker.spring.web.app;
2+
3+
import org.springframework.beans.factory.annotation.Value;
4+
import org.springframework.stereotype.Service;
5+
6+
import java.text.SimpleDateFormat;
7+
import java.util.Date;
8+
9+
@Service
10+
public abstract class AbstractConversionService {
11+
@Value("${app.input-dir}")
12+
protected String inputDir;
13+
14+
@Value("${app.output-dir}")
15+
protected String outputDir;
16+
17+
protected String generateOutputFileName(String inputFilename, String extension) {
18+
String timestamp = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(new Date());
19+
String baseFileName = inputFilename.replaceAll("\\.[^.]+$", "");
20+
return timestamp + "_" + baseFileName + "." + extension;
21+
}
22+
23+
protected void configurePageSetup(com.aspose.html.rendering.PageSetup pageSetup,
24+
Boolean adjustToWidestPage,
25+
Double pageWidth,
26+
Double pageHeight) {
27+
if (pageWidth != null && pageHeight != null) {
28+
pageSetup.setAnyPage(new com.aspose.html.drawing.Page(
29+
new com.aspose.html.drawing.Size(
30+
com.aspose.html.drawing.Length.fromInches(pageWidth),
31+
com.aspose.html.drawing.Length.fromInches(pageHeight)
32+
),
33+
new com.aspose.html.drawing.Margin(0, 0, 0, 0)
34+
));
35+
}
36+
if (adjustToWidestPage != null) {
37+
pageSetup.setAdjustToWidestPage(adjustToWidestPage);
38+
}
39+
}
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package com.aspose.html.sample.docker.spring.web.app;
2+
3+
import org.springframework.beans.factory.annotation.Autowired;
4+
import org.springframework.stereotype.Controller;
5+
import org.springframework.ui.Model;
6+
import org.springframework.web.bind.annotation.*;
7+
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
8+
// другие ваши импорты
9+
10+
@Controller
11+
public class ConversionController {
12+
@GetMapping("/aspose-html-for-java/sample-web-service/convert/{filename}")
13+
public String showConvertPage(@PathVariable String filename, Model model) {
14+
model.addAttribute("filename", filename);
15+
return "convert";
16+
}
17+
18+
@PostMapping("/aspose-html-for-java/sample-web-service/convert")
19+
public String convertFile(@RequestParam String filename,
20+
@RequestParam String outputFormat,
21+
@RequestParam(required = false) Boolean adjustToWidestPage,
22+
@RequestParam(required = false) Double pageWidth,
23+
@RequestParam(required = false) Double pageHeight,
24+
RedirectAttributes redirectAttributes) {
25+
try {
26+
ConversionService conversionService = getConverterForFormat(outputFormat);
27+
String outputPath = conversionService.convert(filename, adjustToWidestPage,
28+
pageWidth, pageHeight);
29+
30+
redirectAttributes.addFlashAttribute("message",
31+
"File successfully converted to " + outputFormat.toUpperCase());
32+
return "redirect:/aspose-html-for-java/sample-web-service/files";
33+
} catch (Exception e) {
34+
redirectAttributes.addFlashAttribute("error", "Conversion error: " + e.getMessage());
35+
return "redirect:/aspose-html-for-java/sample-web-service/convert/" + filename;
36+
}
37+
}
38+
39+
@Autowired
40+
private PdfConversionService pdfConversionService;
41+
42+
@Autowired
43+
private XpsConversionService xpsConversionService;
44+
45+
@Autowired
46+
private PngConversionService pngConversionService;
47+
48+
private ConversionService getConverterForFormat(String format) {
49+
return switch (format.toLowerCase()) {
50+
case "pdf" -> pdfConversionService;
51+
case "xps" -> xpsConversionService;
52+
case "png" -> pngConversionService;
53+
default -> throw new IllegalArgumentException("Unsupported format: " + format);
54+
};
55+
}
56+
}

0 commit comments

Comments
 (0)