Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Demos/Spring/configuration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ annotation:
# Pages preload
# How many pages from a document should be loaded, remaining pages will be loaded on page scrolling
# Set 0 to load all pages at once
preloadPageCount: 0
preloadPageCount: 1
# Fonts path
# Absolute path to custom fonts directory
fontsDirectory:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,38 @@ public PageDataDescriptionEntity loadDocumentPage(@RequestBody LoadDocumentPageR
return annotationService.getDocumentPage(loadDocumentPageRequest);
}

/**
* Get raw page image (PNG) - avoids Base64/JSON overhead for better performance
*
* @param documentGuid document path
* @param page page number (1-based)
* @param password document password (optional)
* @param response http response with PNG image
*/
@RequestMapping(value = "/pageImage", method = RequestMethod.GET, produces = "image/png")
public void getPageImage(@RequestParam("guid") String documentGuid,
@RequestParam("page") int page,
@RequestParam(value = "password", required = false) String password,
HttpServletResponse response) {
try {
byte[] imageBytes = annotationService.getPageImageBytes(documentGuid, page, password);

// Enable browser caching
response.setContentType("image/png");
response.setContentLength(imageBytes.length);
response.setHeader("Cache-Control", "private, max-age=300");

String etag = "\"" + documentGuid.hashCode() + "-" + page + "-" + new java.io.File(documentGuid).lastModified() + "\"";
response.setHeader("ETag", etag);

ServletOutputStream outputStream = response.getOutputStream();
outputStream.write(imageBytes);
outputStream.flush();
} catch (Exception ex) {
throw new TotalGroupDocsException(ex.getMessage(), ex);
}
}

/**
* Download document
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,14 @@ public interface AnnotationService {
* @return stream of annotated document
*/
InputStream annotateByStream(AnnotationPostedDataEntity annotateDocumentRequest);

/**
* Get raw page image bytes (PNG) for streaming endpoint
*
* @param guid document path
* @param pageNumber page number (1-based)
* @param password document password (nullable)
* @return PNG image bytes
*/
byte[] getPageImageBytes(String guid, int pageNumber, String password);
}
Loading