Implementing Document Signing and Stamping with SpringBoot and PageOffice
This article demonstrates how to build a SpringBoot‑based document signing and stamping system using PageOffice, covering digital signature concepts, project structure, key controller and service code, file utilities, QR code generation, deployment steps, and a complete workflow demo with screenshots.
1. Introduction
Digital signatures use cryptographic techniques to verify identity, ensure authenticity, integrity, and non‑repudiation of electronic documents. The article introduces an open‑source system that simulates a file signing and stamping workflow in an OA environment, leveraging PageOffice for online Word/PDF processing and RSA‑based signatures compliant with Chinese e‑signature law.
2. Project Source Code and Deployment
2.1 Project Structure and Framework
The system is built with SpringBoot and Thymeleaf, packaged via Maven.
Controller Layer
@Controller
@RequestMapping("/mobile")
public class MobileOfficeController {
@Value("${docpath}")
private String docPath;
@Value("${moblicpath}")
private String moblicpath;
@Autowired
DocService m_docService;
@RequestMapping("/opendoc")
public void opendoc(HttpServletRequest request, HttpServletResponse response, HttpSession session, String type, String userName) throws Exception {
// ... omitted for brevity ...
}
@RequestMapping("/savedoc")
public void savedoc(HttpServletRequest request, HttpServletResponse response) {
FileSaver fs = new FileSaver(request, response);
fs.saveToFile(docPath + fs.getFileName());
fs.close();
}
}Business Service Layer
@Service
public class DocServiceImpl implements DocService {
@Autowired
DocMapper docMapper;
@Override
public Doc getDocById(int id) throws Exception {
Doc doc = docMapper.getDocById(id);
if (doc == null) { doc = new Doc(); }
return doc;
}
// addDoc, updateStatusForDocById, updateDocNameForDocById, updatePdfNameForDocById ...
}File Copy Utility
public class CopyFileUtil {
public static boolean copyFile(String oldPath, String newPath) throws Exception {
// ... file copy logic ...
}
}QR Code Utility
public class QRCodeUtil {
private String codeText;
private BarcodeFormat barcodeFormat;
private int width;
private int height;
private String imageformat;
private int backColorRGB;
private int codeColorRGB;
private ErrorCorrectionLevel errorCorrectionLevel;
private String encodeType;
// constructors, getters, setters, toBufferedImage, writeToBytes, getQRCodeBytes ...
}2.2 Project Download and Setup
Source code download: https://download.csdn.net/download/weixin_44385486/86427996
Import the slndemo project into IDEA and run.
Copy slndemodata.zip to the D: drive root and unzip.
Start the project.
3. Feature Demonstration
3.1 Login to Home Page
URL: http://localhost:8888/pc/login
Account: 张三 / Password: 123456
3.2 System Home Page Overview
The demo showcases Word document flow: drafting, approval, review, stamping, and final publishing. PageOffice provides over a hundred functions such as open, edit, save, dynamic fill, merge, stamping, etc. The demo creates only one document for simplicity.
3.3 Draft Document
Click “Draft Document” and submit.
3.4 Edit and Save
After installing PageOffice plugin, edit the document, then click “Save”.
3.5 Approval Workflow
Various users (李总, 赵六, 王五) log in to approve, review, and finally stamp the document. The process includes password‑protected stamping and signature.
3.6 Final Signed and Stamped Document
After saving, the completed document is displayed.
4. Conclusion
The demo provides a practical reference for integrating digital signatures and electronic stamping into Java web applications using SpringBoot and PageOffice, and can be adapted to other OA or document‑centric systems.
Java Architect Essentials
Committed to sharing quality articles and tutorials to help Java programmers progress from junior to mid-level to senior architect. We curate high-quality learning resources, interview questions, videos, and projects from across the internet to help you systematically improve your Java architecture skills. Follow and reply '1024' to get Java programming resources. Learn together, grow together.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.