You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a condensed reference for the classes and methods demonstrated in this solution. For full API documentation, see the official docs.
Licensing
usingExis.PdfEditor;// Initialize with evaluation mode (watermarked output)ExisLicense.Initialize();// Initialize with a license keyExisLicense.Initialize("YOUR-LICENSE-KEY");
PdfEditor — Open & Edit Existing PDFs
// Open an existing PDFusingvareditor=awaitPdfEditor.OpenAsync("input.pdf");// Open with passwordusingvareditor=awaitPdfEditor.OpenAsync("encrypted.pdf","password");
Find & Replace
// Simple replacement — returns count of replacements madeintcount=editor.FindReplace("old text","new text");// Batch replacementintcount=editor.FindReplace(newDictionary<string,string>{["{{PLACEHOLDER}}"]="Actual Value",["{{DATE}}"]=DateTime.Now.ToShortDateString()});// Regex replacementintcount=editor.FindReplaceRegex(@"\b\d{3}-\d{2}-\d{4}\b","[REDACTED]");// With optionsintcount=editor.FindReplace("text","replacement",newFindReplaceOptions{PageRange=newPageRange(1,3),TextFitting=TextFitting.ShrinkToFit});
Merge & Split
// Merge multiple PDFsawaitPdfEditor.MergeAsync(new[]{"a.pdf","b.pdf","c.pdf"},"merged.pdf");// Split into chunks of N pagesvarfiles=awaiteditor.SplitAsync("output-dir",pagesPerFile:5);// Extract specific pagesawaiteditor.ExtractPagesAsync(new[]{1,3,5},"extracted.pdf");// Split into individual page filesvarfiles=awaiteditor.SplitToFilesAsync("output-dir");
Redaction
// Redact by texteditor.Redact("confidential text");// Redact by regex patterneditor.RedactRegex(@"\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b");// Redact with replacement texteditor.Redact("secret",newRedactionOptions{ReplacementText="[REDACTED]"});// Area-based redaction (x, y, width, height in points)editor.RedactArea(100,700,200,20,pageNumber:1);
Text Extraction
// Simple text extractionstringtext=editor.ExtractText();// Structured extraction (preserves layout)varstructured=editor.ExtractStructuredText();// Extract from specific pagesstringtext=editor.ExtractText(newPageRange(1,5));
Form Operations
// Read form fieldsvarfields=editor.GetFormFields();foreach(varfieldinfields)Console.WriteLine($"{field.Name}: {field.Value} ({field.FieldType})");// Fill form fieldseditor.SetFormField("FirstName","John");editor.SetFormField("LastName","Doe");// Flatten form (make fields non-editable)editor.FlattenForm();
// Validatevarresult=editor.ValidatePdfA();Console.WriteLine($"Compliant: {result.IsCompliant}, Standard: {result.Standard}");// Convert to PDF/Aawaiteditor.ConvertToPdfAAsync(PdfAStandard.PdfA2b);
Digital Signatures
// Sign a PDFawaiteditor.SignAsync(newSignatureOptions{CertificatePath="cert.pfx",CertificatePassword="password",Reason="Approval",Location="New York"});// Verify signaturesvarresult=editor.VerifySignature();Console.WriteLine($"Valid: {result.IsValid}, Signer: {result.SignerName}");// Verify all signaturesvarresults=editor.VerifyAll();
Save
// Save to new fileawaiteditor.SaveAsync("output.pdf");// Get metadataintpages=editor.PageCount;string?author=editor.Author;string?title=editor.Title;
PdfBuilder — Create PDFs from Scratch
usingvarbuilder=newPdfBuilder();// Add a page and draw contentbuilder.AddPage(PageSize.A4).SetFont("Helvetica",24).DrawText("Hello, World!",50,750).SetFont("Helvetica",12).DrawText("Built with Exis.PdfEditor",50,720).SetFillColor(37,99,235).DrawRectangle(50,600,200,30).SetFillColor(255,255,255).DrawText("Colored box",60,607);// Add another pagebuilder.AddPage().SetFont("Helvetica",12).DrawText("Page 2 content",50,750);// Saveawaitbuilder.SaveAsync("created.pdf");