PdfHelper¶
PdfHelper is a static utility type providing three unrelated helpers used across the library and by the consuming PdfAPI application: AcroForm field detection, form flattening, and construction of a standardized ApplicationExceptionDetail diagnostic record for logging caught exceptions.
Purpose¶
- Detect whether a PDF has AcroForm fields present (BR-SFC-034).
- Flatten a PDF's form fields to make them non-editable, when a form is present (BR-SFC-035, BR-SFC-036).
- Build a standardized
ApplicationExceptionDetailrecord from a caught exception, always attributing it to thePdfApiapplication (BR-SFC-037, BR-SFC-038).
Context¶
- Namespace:
PdfAPI.SyncFusionCore - Assembly/package:
PdfAPI.SyncFusionCore(Pdf.Local.ClientNuGet package)
Public members¶
| Member | Signature | Purpose |
|---|---|---|
| HasFormFields | static bool HasFormFields(byte[] pdf) |
Executes Inspect and flatten PDF form fields (OP-SFC-013) detection step: loads the bytes as a PdfLoadedDocument and returns whether doc.Form is non-null. |
| Flatten | static byte[] Flatten(byte[] inputPdf) |
Executes Inspect and flatten PDF form fields (OP-SFC-013) flatten step: when the loaded document has a non-null Form, sets Form.Flatten = true, saves, and returns the new bytes; otherwise returns the input bytes unchanged. |
| GetApplicationDetail | static ApplicationExceptionDetail GetApplicationDetail(IEnvironmentService envSvc, string page, string message, Exception ex) |
Executes Build an application exception detail (OP-SFC-014): constructs a SAIF.Core.Contracts.ApplicationExceptionDetail with Application = "PdfApi", the caller's environment/machine/user context, the supplied page/message, and ex.GetFullFormattedException() as State. |
Behavioral notes¶
HasFormFieldsandFlattentreat "no form present" as a normal, non-error case rather than an exceptional one.GetApplicationDetailperforms no logging or I/O itself; it only constructs the record — the caller is responsible for passing it toILogService.
Constraints and usage notes¶
- All three members are static; this type is never instantiated.
Related documentation¶
Sources¶
PdfApi.SyncFusionCore\PdfHelper.cs