Migrate from PSWritePDF to PSWriteOffice
Edit on GitHubReplace legacy PSWritePDF and iText-based scripts with maintained OfficeIMO PDF commands for authoring, extraction, forms, and merge.
PSWritePDF is superseded by the OfficePdf command family in PSWriteOffice. New development should use PSWriteOffice and the first-party OfficeIMO.Pdf engine.
This migration changes both the command surface and the PDF engine. Do not assume byte-for-byte output or identical handling of fonts, forms, signatures, annotations, tagged content, encryption, or malformed inputs. Preserve known-good fixtures and compare the rendered and structural result before replacing a production workflow.
Common command replacements
| PSWritePDF | PSWriteOffice | Migration note |
|---|---|---|
New-PDF, New-PDFDocument | New-OfficePdf | Compose content with Add-OfficePdf* commands inside the document block. |
Merge-PDF | Join-OfficePdf | Write the combined result to a new path and reopen it for verification. |
Split-PDF | Split-OfficePdf | Confirm page ranges and output naming for the caller. |
Convert-PDFToText | Get-OfficePdfText | PDF text extraction follows document content, not visual OCR; use an OCR workflow for scanned pages. |
Get-PDFDetails | Get-OfficePdfInfo | Additional inspection commands expose fonts, images, forms, signatures, compliance, and diagnostics. |
Set-PDFForm | Set-OfficePdfForm | Validate field names, appearances, flattening, and permission restrictions. |
Convert-HTMLToPDF | ConvertFrom-OfficePdfHtml | Review the supported HTML/CSS profile and supply trusted-resource settings deliberately. |
| legacy save helpers | Save-OfficePdf | Use explicit output paths and preserve the source during migration. |
Create a PDF with PSWriteOffice
$rows = @(
[pscustomobject]@{ Service = 'API'; Status = 'Healthy' }
[pscustomobject]@{ Service = 'Worker'; Status = 'Healthy' }
)
New-OfficePdf -Path '.\Output\Status.pdf' {
Add-OfficePdfHeading -Text 'Service status' -Level 1
Add-OfficePdfParagraph -Text 'Generated by PSWriteOffice.'
Add-OfficePdfTable -InputObject $rows
}
Replace standalone operations
Join-OfficePdf -Path '.\Cover.pdf', '.\Body.pdf' -OutputPath '.\Combined.pdf'
Split-OfficePdf -Path '.\Combined.pdf' -OutputDirectory '.\Pages'
$info = Get-OfficePdfInfo -Path '.\Combined.pdf'
$text = Get-OfficePdfText -Path '.\Combined.pdf'
Use the generated command reference to confirm the current parameter sets; the legacy command names and parameter semantics are not retained as compatibility aliases.
Validate before replacing the old job
- render representative pages and compare fonts, wrapping, spacing, images, tables, and page breaks;
- inspect forms, annotations, attachments, bookmarks, signatures, encryption, and permission restrictions;
- run
Get-OfficePdfPreflight,Get-OfficePdfDiagnostic, orTest-OfficePdfRewritefor complex inputs; - distinguish native text extraction from OCR for image-only pages;
- verify HTML and CSS resources in the actual deployment environment;
- retain the original PDF and write migration output to a new artifact until acceptance.
See PDF automation and the generated PowerShell command reference for current syntax.