Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/

Migrate from PSWritePDF to PSWriteOffice

Edit on GitHub

Replace 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

PSWritePDFPSWriteOfficeMigration note
New-PDF, New-PDFDocumentNew-OfficePdfCompose content with Add-OfficePdf* commands inside the document block.
Merge-PDFMerge-OfficeDocumentWrite the combined result to a new path and reopen it for verification.
Split-PDFSplit-OfficeDocumentConfirm page ranges and output naming for the caller.
Convert-PDFToTextRead-OfficeDocument -As TextPDF text extraction follows document content, not visual OCR; use an OCR workflow for scanned pages.
Get-PDFDetailsGet-OfficeDocumentInfo -DetailedAdditional inspection commands expose fonts, images, forms, signatures, compliance, and diagnostics.
Set-PDFFormSet-OfficePdfFormFieldValidate field names, appearances, flattening, and permission restrictions.
Convert-HTMLToPDFConvert-OfficeDocument -From Html -To PdfReview the supported HTML/CSS profile and supply trusted-resource settings deliberately.
legacy save helpersSave-OfficePdfUse 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

Merge-OfficeDocument -Path '.\Cover.pdf', '.\Body.pdf' -OutputPath '.\Combined.pdf'
Split-OfficeDocument -Path '.\Combined.pdf' -OutputDirectory '.\Pages'

$info = Get-OfficeDocumentInfo -Path '.\Combined.pdf' -Detailed
$info.Details
$text = Read-OfficeDocument -Path '.\Combined.pdf' -As Text

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-OfficePdfDiagnostic -Type Preflight, Get-OfficePdfDiagnostic, or Test-OfficePdfRewrite for 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.

API used on this page

Example source