Spire.PDF for Java 12.6.1 supports SHA-256/SHA-512 digital signatures

Spire.PDF for Java 12.6.1 supports SHA-256/SHA-512 digital signatures

2026-06-04 08:41:03

We’re excited to announce the release of Spire.PDF for Java 12.6.1. This update introduces support for digitally signing PDFs with SHA-256/SHA-512 certificates and allows setting a fallback font when converting OFD to PDF. In addition, it resolves several issues related to PDF conversion and text extraction.

Here is a list of changes made in this release

Category ID Description
New Feature SPIREPDF-7829 Added support for signing with SHA-256/SHA-512 algorithm certificates.
public static void main(String[] args) throws IOException {
        // Create pdf document
        PdfDocument doc = new PdfDocument();
        // Load file from disk
        doc.loadFromFile("Sample.docx");
        // Load the X509 certificate for signature
        PdfPKCS7Formatter formatter = new PdfPKCS7Formatter(new PdfCertificate("gary.pfx", "e-iceblue"), false);
        // Create an instance of PdfOrdinarySignatureMaker using the loaded document and certificate
        PdfOrdinarySignatureMaker signatureMaker = new PdfOrdinarySignatureMaker(doc, formatter);
        // Create an instance of PdfCustomSignatureAppearance as the appearance for the signature
        IPdfSignatureAppearance signatureAppearance = new PdfCustomSignatureAppearance();
        // Make the signature with a specified name and the custom appearance
        signatureMaker.makeSignature("Signature", signatureAppearance);
        // Iterate through all hash algorithm types
        for (HashAlgorithmType hashAlg : HashAlgorithmType.values()) {
        // Skip SM3 (case-insensitive)
            if ("SM3".equalsIgnoreCase(hashAlg.name())) {
                continue;
            }
            try {
                // Set the current hash algorithm
                formatter.getProperties().setHashAlgorithm(hashAlg);
                String filePath = "AddImageSignature_" + hashAlg.name() + ".pdf";
                doc.saveToFile(filePath, FileFormat.PDF);
                System.out.println("Succeed:" + hashAlg.name());
            } catch (Exception ex) {
                System.out.println("Error HashAlgorithmType:" + hashAlg.name());
                System.out.println("Error Info:" + ex.getMessage());
            }
        }
        // Close the document
        doc.close();
    }
    // Custom signature appearance implementation
    public static class PdfCustomSignatureAppearance implements IPdfSignatureAppearance {
        @Override
        public void generate(PdfCanvas pdfCanvas) {
            // Set font size
            int fontSize = 10;
            // Create Arial font
            PdfTrueTypeFont font = new PdfTrueTypeFont(new Font("Arial", Font.PLAIN, fontSize), true);
            // Set line height
            float lineHeight = fontSize;
            // Draw text string
            pdfCanvas.drawString("AAAAAAAAAAA", font, PdfBrushes.getRed(), new Point.Float(0, 0));
            // Draw image at specified position
            pdfCanvas.drawImage(PdfImage.fromFile("E-iceblue logo.png"), new Point.Float(20, 0));
        }
    }
New Feature SPIREPDF-8077 Added support for setting a fallback font when converting OFD to PDF.
OfdConverter converter = new OfdConverter(ofdFile.getAbsolutePath());
converter.getOptions().setDefaultFontName(fontName);
converter.toPdf(PdfPath);
New Feature SPIREPDF-8078 Added a progress callback for OFD to PDF conversion.
CustomProgressNotifier progressNotifier =new CustomProgressNotifier(output_txt);
    ofdConverter ofdconverter=new Ofdconverter(inputPath);
    ofdconverter.registerProgressNotifier(progressNotifier);
    ofdConverter.toPdf(outputPath);

    CustomProgressNotifier progressNotifier2=new CustomProgressNotifier(output_txt2);
    PdfToWordConverter converter=new PdfTowordConverter(inputPath2);
    converter.registerProgressNotifier(progressNotifier2);
    converter.saveToDocx(outputPath2)
Bug Fix SPIREPDF-8040 Fixed the issue where loading a PDF without a permission password caused an exception.
Bug Fix SPIREPDF-8060 Fixed the issue where converting an image to PDF caused an exception.
Bug Fix SPIREPDF-8065 Fixed the issue where checkmarks were missing when converting PDF to PDFA.
Bug Fix SPIREPDF-8067 Fixed the issue where extracted PDF text contained garbled characters.
Bug Fix SPIREPDF-8079 Fixed the issue where PDF-to-SVG conversion displayed incorrect content in browsers.
Click the link below to download Spire.PDF for Java 12.6.1: