Build a Java SpringBoot Digital Signature & Seal System with PageOffice
This article walks through creating a Java SpringBoot demo that implements digital signing and electronic sealing of Office documents, explains the underlying cryptographic concepts, shows the full source code (controller, service, utility classes), and provides step‑by‑step deployment and UI demonstration of the workflow.
Introduction
The company needed a feature to sign and seal documents electronically. Digital signatures use cryptographic techniques to verify identity, ensure authenticity, integrity, and non‑repudiation of documents such as Word files, PDFs, emails, and macros. The demo simulates an OA system where Word documents flow through drafting, approval, sealing, and final publishing, using PageOffice for online editing and a custom seal verification engine that complies with China’s Electronic Signature Law and supports RSA.
Source Code and Deployment
Project Structure and Framework
The project is built with SpringBoot and Thymeleaf, managed by Maven. It provides both PC (PageOffice) and mobile (MobOffice) interfaces for document handling.
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 {
// simplified logic for opening a document
}
@RequestMapping("/savedoc")
public void savedoc(HttpServletRequest request, HttpServletResponse response) {
FileSaver fs = new FileSaver(request, response);
fs.saveToFile(docPath + fs.getFileName());
fs.close();
}
}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;
}
@Override
public Integer addDoc(Doc doc) throws Exception {
int id = docMapper.addDoc(doc);
return id;
}
// other CRUD methods omitted for brevity
}File Copy Utility
public class CopyFileUtil {
// copy file from oldPath to newPath
public static boolean copyFile(String oldPath, String newPath) throws Exception {
// implementation omitted for brevity
}
}QR Code Utility
public class QRCodeUtil {
private String codeText = "www.zhuozhengsoft.com";
private BarcodeFormat barcodeFormat = BarcodeFormat.PDF_417;
private int width = 400;
private int height = 400;
private String imageformat = "png";
private int backColorRGB = 0xFFFFFFFF;
private int codeColorRGB = 0xFF000000;
private ErrorCorrectionLevel errorCorrectionLevel = ErrorCorrectionLevel.H;
private String encodeType = "UTF-8";
// getters, setters, and methods to generate QR code bytes omitted for brevity
}Download and Deployment
Contact the author via WeChat (ID: fenggejava) and reply “盖章系统” to receive the source package.
After downloading, unzip the slndemodata.zip package to D:\ and import the slndemo project into IntelliJ IDEA.
Run the SpringBoot application; the demo will be accessible at http://localhost:8888/pc/login (default credentials: 张三 / 123456).
Feature Demonstration
Login to the system and start a new draft document.
Edit the document online; PageOffice prompts installation of the client plugin if missing.
Save the draft, submit for approval, and let different users (李总, 赵六, 王五) review, approve, and finally apply an electronic seal.
During sealing, the user must enter a valid username and password (e.g., 王五 / 123456) to select a personal seal.
After signing and sealing, the final document can be saved and published.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java High-Performance Architecture
Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.
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.
