문서 저장
1.클라이언트
JS저장
// 편집 후 저장
await viewer.save();fetcher.save는 백엔드 연동 (fetcher)에서 지정합니다. 저장 진행 상태는 이벤트 (BEGIN_DOCUMENT_SAVE / DOCUMENT_SAVED)로 감지할 수 있습니다.
2.서버
JAVA저장 엔드포인트
@PostMapping("/document/{name}/save/{saveName}")
public Document save(@PathVariable String name, @PathVariable String saveName,
@RequestPart("document") Document document,
@RequestPart(name = "imageFileList", required = false) MultipartFile[] imageFileList) throws IOException {
HashMap<String, byte[]> imageFileMap = toMap(imageFileList);
document.applyToPDF(pdfPath.resolve(name), imageFileMap); // 모델 → PDF 반영
document.saveToPDF(pdfPath.resolve(saveName), cachePath.resolve(saveName)); // 저장
return document; // 갱신된 문서 반환
}• 원본 이름과 저장 이름
name(원본)과 saveName(저장 대상)을 다르게 주면 다른 이름으로, 같게 주면 원본에 덮어써 저장됩니다. 저장은 임시 파일에 쓴 뒤 교체하므로 실패해도 원본은 보존됩니다.