Skip to content

Commit 0fc646b

Browse files
Added and configured groupdocs-viewer-ui v23.7.
1 parent f661f51 commit 0fc646b

File tree

5 files changed

+152
-0
lines changed

5 files changed

+152
-0
lines changed
Binary file not shown.

samples/groupdocs-viewer-java-ui-spring-boot/pom.xml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,28 @@
2727
<artifactId>spring-boot-starter-test</artifactId>
2828
<scope>test</scope>
2929
</dependency>
30+
31+
<dependency>
32+
<groupId>com.groupdocs</groupId>
33+
<artifactId>groupdocs-viewer-ui</artifactId>
34+
<version>23.7</version>
35+
</dependency>
36+
37+
<dependency>
38+
<groupId>com.groupdocs</groupId>
39+
<artifactId>groupdocs-viewer</artifactId>
40+
<version>23.7</version>
41+
</dependency>
42+
<dependency>
43+
<groupId>com.fasterxml.jackson.core</groupId>
44+
<artifactId>jackson-databind</artifactId>
45+
<version>2.13.4.1</version>
46+
</dependency>
47+
<dependency>
48+
<groupId>com.fasterxml.jackson.core</groupId>
49+
<artifactId>jackson-annotations</artifactId>
50+
<version>2.13.3</version>
51+
</dependency>
3052
</dependencies>
3153

3254
<build>
@@ -38,4 +60,12 @@
3860
</plugins>
3961
</build>
4062

63+
<repositories>
64+
<repository>
65+
<id>releases.groupdocs.com</id>
66+
<name>releases.groupdocs</name>
67+
<url>https://releases.groupdocs.com/java/repo/</url>
68+
</repository>
69+
</repositories>
70+
4171
</project>

samples/groupdocs-viewer-java-ui-spring-boot/src/main/java/com/example/groupdocsviewerjavauispringboot/DemoApplication.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,41 @@
11
package com.example.groupdocsviewerjavauispringboot;
22

3+
import com.groupdocs.viewerui.handler.JakartaViewerEndpointHandler;
4+
import jakarta.servlet.http.HttpServletRequest;
5+
import jakarta.servlet.http.HttpServletResponse;
36
import org.springframework.boot.SpringApplication;
47
import org.springframework.boot.autoconfigure.SpringBootApplication;
8+
import org.springframework.web.bind.annotation.GetMapping;
9+
import org.springframework.web.bind.annotation.PostMapping;
510
import org.springframework.web.bind.annotation.RequestMapping;
611
import org.springframework.web.bind.annotation.RestController;
712

813
@RestController
914
@SpringBootApplication
1015
public class DemoApplication {
16+
private final JakartaViewerEndpointHandler _viewerEndpointHandler;
17+
18+
public DemoApplication(JakartaViewerEndpointHandler endpointHandler) {
19+
this._viewerEndpointHandler = endpointHandler;
20+
}
1121

1222
@RequestMapping("/")
1323
String home() {
1424
return "<html><body><p>groupdocs-viewer-java-ui-spring-boot</p><p><a href=\"/viewer/\">Open GroupDocs.Viewer page</a></p><body/></html>";
1525
}
1626

27+
@GetMapping({ ViewerConfiguration.VIEWER_UI_PATH, ViewerConfiguration.VIEWER_UI_PATH + "/**",
28+
ViewerConfiguration.VIEWER_CONFIG_ENDPOINT, ViewerConfiguration.VIEWER_CONFIG_ENDPOINT + "/**",
29+
ViewerConfiguration.VIEWER_API_ENDPOINT, ViewerConfiguration.VIEWER_API_ENDPOINT + "/**" })
30+
public void handleViewerUiRequest(HttpServletRequest request, HttpServletResponse response) {
31+
this._viewerEndpointHandler.handleViewerRequest(request, response);
32+
}
33+
34+
@PostMapping({ ViewerConfiguration.VIEWER_API_ENDPOINT, ViewerConfiguration.VIEWER_API_ENDPOINT + "/**" })
35+
public void handleViewerApiRequest(HttpServletRequest request, HttpServletResponse response) {
36+
this._viewerEndpointHandler.handleViewerRequest(request, response);
37+
}
38+
1739
public static void main(String[] args) {
1840
SpringApplication.run(DemoApplication.class, args);
1941
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package com.example.groupdocsviewerjavauispringboot;
2+
3+
import com.groupdocs.viewerui.handler.JakartaViewerEndpointHandler;
4+
import com.groupdocs.viewerui.ui.core.ViewerType;
5+
import jakarta.annotation.PostConstruct;
6+
import org.springframework.context.annotation.Bean;
7+
import org.springframework.context.annotation.Configuration;
8+
9+
import java.nio.file.Paths;
10+
11+
@Configuration
12+
public class ViewerConfiguration {
13+
public static final String VIEWER_UI_PATH = "/viewer";
14+
15+
public static final String VIEWER_CONFIG_ENDPOINT = "/viewer-config";
16+
17+
public static final String VIEWER_API_ENDPOINT = "/viewer-api";
18+
19+
private JakartaViewerEndpointHandler _viewerEndpointHandler;
20+
21+
@PostConstruct
22+
public void init() {
23+
_viewerEndpointHandler = JakartaViewerEndpointHandler
24+
.setupGroupDocsViewer((viewerConfig, config) -> {
25+
viewerConfig.setViewerType(ViewerType.PNG);
26+
27+
config.setPreloadPageCount(2);
28+
config.setBaseUrl("http://localhost:8080");
29+
})
30+
31+
.setupGroupDocsViewerUI(uiOptions -> {
32+
uiOptions.setUiPath(VIEWER_UI_PATH);
33+
uiOptions.setUiConfigEndpoint(VIEWER_CONFIG_ENDPOINT);
34+
})
35+
.setupGroupDocsViewerApi(apiOptions -> {
36+
apiOptions.setApiEndpoint(VIEWER_API_ENDPOINT);
37+
})
38+
.setupLocalStorage(Paths.get("./files").toAbsolutePath())
39+
.setupInMemoryCache(inMemoryCacheConfig -> {
40+
inMemoryCacheConfig.setGroupCacheEntriesByFile(false);
41+
inMemoryCacheConfig.setCacheEntryExpirationTimeoutMinutes(3);
42+
})
43+
// .setupLocalCache(cacheConfig -> {
44+
// cacheConfig.setCachePath(Paths.get("/home/liosha/workspace/groupdocs/files/cache"));
45+
// })
46+
;
47+
}
48+
49+
@Bean
50+
public JakartaViewerEndpointHandler viewerEndpointHandler() {
51+
return _viewerEndpointHandler;
52+
}
53+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<configuration>
3+
4+
<property name="LOGS" value="./logs" />
5+
6+
<appender name="Console"
7+
class="ch.qos.logback.core.ConsoleAppender">
8+
<layout class="ch.qos.logback.classic.PatternLayout">
9+
<Pattern>
10+
%black(%d{ISO8601}) %highlight(%-5level) [%blue(%t)] %yellow(%C{1}): %msg%n%throwable
11+
</Pattern>
12+
</layout>
13+
</appender>
14+
15+
<appender name="RollingFile"
16+
class="ch.qos.logback.core.rolling.RollingFileAppender">
17+
<file>${LOGS}/spring-boot-logger.log</file>
18+
<encoder
19+
class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
20+
<Pattern>%d %p %C{1} [%t] %m%n</Pattern>
21+
</encoder>
22+
23+
<rollingPolicy
24+
class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
25+
<!-- rollover daily and when the file reaches 10 MegaBytes -->
26+
<fileNamePattern>${LOGS}/archived/spring-boot-logger-%d{yyyy-MM-dd}.%i.log
27+
</fileNamePattern>
28+
<timeBasedFileNamingAndTriggeringPolicy
29+
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
30+
<maxFileSize>10MB</maxFileSize>
31+
</timeBasedFileNamingAndTriggeringPolicy>
32+
</rollingPolicy>
33+
</appender>
34+
35+
<!-- LOG everything at INFO level -->
36+
<root level="info">
37+
<appender-ref ref="RollingFile" />
38+
<appender-ref ref="Console" />
39+
</root>
40+
41+
<!-- LOG "com.baeldung*" at TRACE level -->
42+
<logger name="com.groupdocs" level="debug" additivity="false">
43+
<appender-ref ref="RollingFile" />
44+
<appender-ref ref="Console" />
45+
</logger>
46+
47+
</configuration>

0 commit comments

Comments
 (0)