Skip to content

Instantly share code, notes, and snippets.

@GroupDocsGists
GroupDocsGists / CreateCertificateForVaultKey.cs
Created November 7, 2026 09:10
External PDF signing in C#: an ICustomSignHash signer backed by Vault Transit, a certificate for a non-exportable key, prehashed pkcs1v15 requests, and cryptographic verification
// Body of CertificateHelper.CreateSelfSignedCertificate. The private key cannot leave
// Vault, so the certificate is built around the Vault public key and Vault signs it too.
// Inputs: vault (VaultTransitClient), keyName, key (version + public key PEM from Vault).
using RSA publicKey = RSA.Create();
publicKey.ImportFromPem(key.PublicKeyPem);
var subject = new X500DistinguishedName("CN=Vault Transit Signer");
var request = new CertificateRequest(
subject, publicKey, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1);
@GroupDocsGists
GroupDocsGists / Program.cs
Created November 6, 2026 10:33
How to Redact Text in Documents on Windows
using GroupDocs.Redaction;
using GroupDocs.Redaction.Options;
using GroupDocs.Redaction.Redactions;
using System.Text.RegularExpressions;
Console.WriteLine("======================================");
Console.WriteLine("Redact phrase using Regex with GroupDocs.Redaction");
// This project uses the Windows-specific build of GroupDocs.Redaction for .NET
// to improve compatibility with applications running on Windows.
@GroupDocsGists
GroupDocsGists / EnsureMcpServerConfig.cs
Created November 2, 2026 15:38
Docker MCP registration plus get_document_info, extract_text, and extract_tables Markdown mirrors using GroupDocs.Parser for .NET.
// JSON for MCP clients: docker run --rm -i -v <host>:/data <image>
string normalizedHost = hostDocumentsPath.Replace('\\', '/');
var payload = new
{
mcpServers = new
{
groupdocs_parser = new
{
command = "docker",
args = new[]
@GroupDocsGists
GroupDocsGists / ChunkMarkdownByHeadings.cs
Created November 2, 2026 15:38
Extract Markdown via GetFormattedText, fall back with GetText for PDF, then split on # / ## headings in C#.
string markdown = File.ReadAllText("Result/sample.md", Encoding.UTF8);
string outputDirectory = "Result/chunks";
Directory.CreateDirectory(outputDirectory);
foreach (string stale in Directory.EnumerateFiles(
outputDirectory, "chunk-*.md"))
{
File.Delete(stale);
}
@GroupDocsGists
GroupDocsGists / CompareAsPlainText.cs
Created October 29, 2026 14:56
OCR-based image comparison with GroupDocs.Comparison for .NET 26.10 - compare scanned images by recognized text, pick a display mode, select a language, read change coordinates, run offline
// Render the comparison as a plain stream of recognized words.
using var comparer = new Comparer(sourcePath);
comparer.Add(targetPath);
var options = new CompareOptions
{
Ocr = new OcrOptions
{
Enabled = true,
@GroupDocsGists
GroupDocsGists / README.md
Created October 29, 2026 11:28
GroupDocs.Parser for Java as a Spring AI DocumentReader: page-level Documents, email attachment lineage and TokenTextSplitter chunks for RAG

Spring AI DocumentReader for Office, PDF and email in Java - Q&A with GroupDocs.Parser

A Spring AI DocumentReader for Office, PDF and email is a GroupDocs.Parser capability for Java that reads Word, PDF, EML/MSG messages with attachments and ZIP archives into Spring AI Document objects, one per page, with source, page_number and parent_source metadata.

This gist answers the questions Java developers ask when they plug GroupDocs.Parser for Java into the Spring AI ETL pipeline. Each answer names the real class and method involved and points to the code file that shows it. Every file holds the body of one method from a runnable Maven project; its first comment line names the method.

Files in this gist

  • README.md - this Q&A overview.
  • ReadResourceIntoDocuments.java - the DocumentReader get() entry point.
@GroupDocsGists
GroupDocsGists / ChunkAttachments.java
Created October 29, 2026 11:28
Split DOCX, PDF, email and ZIP files into Markdown chunks with source and parent lineage, written as JSON Lines, using GroupDocs.Parser for Java
// Body of chunkContainerItems(Parser parser, String sourceId, int depth).
// EML/MSG attachments and ZIP entries come back as ContainerItem objects.
List<Chunk> chunks = new ArrayList<>();
Iterable<ContainerItem> items = parser.getContainer();
if (items == null) {
return chunks; // not a container format
}
for (ContainerItem item : items) {
// e.g. "email-with-attachment.eml/attachment.txt"
String childId = sourceId + "/" + item.getFilePath();
@GroupDocsGists
GroupDocsGists / README.md
Created October 9, 2026 14:44
The 26.9 default change in runnable Python: skip_external_resources, whitelisted_resources, three preview sizes that prove what was fetched, and signing an untrusted DOCX with no network access

Safe document loading in Python - GroupDocs.Signature tutorial snippets

Safe loading is a GroupDocs.Signature policy for Python that leaves a document's linked addresses unrequested while the file is opened.

Five small snippets covering the behaviour change in GroupDocs.Signature 26.9: the same DOCX previewed under three load policies, and signed without touching the network. Download them into one directory, add a document whose picture is linked rather than embedded, and run any file directly.

Files in this gist

  • README.md - this overview.
  • preview_with_default_settings.py - the safe default; nothing linked is fetched.
@GroupDocsGists
GroupDocsGists / README.md
Created October 9, 2026 13:56
Sign DOCX with ML-DSA (FIPS 204) certificates from Python via .NET: one DigitalSignOptions call, all three NIST levels with measured sizes, verification by public certificate, and signature search

ML-DSA Word signing - runnable Python mini-project for GroupDocs.Signature

Quantum-safe signing is a GroupDocs.Signature capability for Python that applies a FIPS 204 ML-DSA key to a DOCX through the same call that applies an RSA one.

Four short files that sign a DOCX with post-quantum certificates, compare the three NIST security levels on measured output, verify the result against a public certificate, and read the signature back out. Download them into one directory, add an ML-DSA PFX, and run.

Project layout

  • documents/ - the source DOCX and your ML-DSA certificates (mldsa44.pfx, mldsa65.pfx, mldsa87.pfx, mldsa65.cer).
  • Result/ - the signed documents, created on the first run.
@GroupDocsGists
GroupDocsGists / README.md
Created October 9, 2026 12:25
Digital signing from Python via .NET: hash_algorithm, the 26.9 refusal to sign with an expired certificate, allow_expired and allow_not_yet_valid, and a log level that filters

Certificate checks and log levels in Python - Q&A with GroupDocs.Signature

Expired-certificate refusal is a GroupDocs.Signature capability for Python that declines to sign with a certificate that has run out, or has not yet come into force.

This gist is organised around the questions developers actually ask about digital signing from Python (via .NET): which digest gets written, what happens when the certificate is out of date, how to override that on purpose, and how to stop the library filling the log. Every answer is grounded in GroupDocs.Signature 26.10.0 APIs and names the file that runs it.

Files in this gist

  • README.md - this Q&A overview.
  • sign_with_hash_algorithm.py - choose SHA-256, SHA-384 or SHA-512 for a PDF signature.