Skip to content
This repository was archived by the owner on Oct 18, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 88 additions & 16 deletions Docs/Generated/PSWriteOffice-help.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54442,9 +54442,9 @@ cells. This keeps existing-document editing simple without forcing callers back
<maml:description>
<maml:para>Font size in points.</maml:para>
</maml:description>
<command:parameterValue required="false" variableLength="false">Int32</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Double</command:parameterValue>
<dev:type>
<maml:name>Int32</maml:name>
<maml:name>Double</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
Expand Down Expand Up @@ -54585,9 +54585,9 @@ cells. This keeps existing-document editing simple without forcing callers back
<maml:description>
<maml:para>Font size in points.</maml:para>
</maml:description>
<command:parameterValue required="false" variableLength="false">Int32</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Double</command:parameterValue>
<dev:type>
<maml:name>Int32</maml:name>
<maml:name>Double</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
Expand Down Expand Up @@ -54728,9 +54728,9 @@ cells. This keeps existing-document editing simple without forcing callers back
<maml:description>
<maml:para>Font size in points.</maml:para>
</maml:description>
<command:parameterValue required="false" variableLength="false">Int32</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Double</command:parameterValue>
<dev:type>
<maml:name>Int32</maml:name>
<maml:name>Double</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
Expand Down Expand Up @@ -75274,6 +75274,18 @@ cells. This keeps existing-document editing simple without forcing callers back
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="False" position="named" aliases="None">
<maml:name>IgnorePermissionRestrictions</maml:name>
<maml:description>
<maml:para>After successful password authentication, explicitly ignore owner-imposed extraction restrictions.</maml:para>
</maml:description>
<command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue>
<dev:type>
<maml:name>SwitchParameter</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="None">
<maml:name>Language</maml:name>
<maml:description>
Expand Down Expand Up @@ -75376,6 +75388,18 @@ cells. This keeps existing-document editing simple without forcing callers back
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="False" position="named" aliases="None">
<maml:name>Password</maml:name>
<maml:description>
<maml:para>Password used to authenticate an encrypted PDF.</maml:para>
</maml:description>
<command:parameterValue required="false" variableLength="false">String</command:parameterValue>
<dev:type>
<maml:name>String</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="FilePath">
<maml:name>Path</maml:name>
<maml:description>
Expand All @@ -75400,6 +75424,18 @@ cells. This keeps existing-document editing simple without forcing callers back
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="False" position="named" aliases="None">
<maml:name>ReadOptions</maml:name>
<maml:description>
<maml:para>Optional bounded PDF parsing settings.</maml:para>
</maml:description>
<command:parameterValue required="false" variableLength="false">PdfLoadOptions</command:parameterValue>
<dev:type>
<maml:name>PdfLoadOptions</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="False" position="named" aliases="None">
<maml:name>RenderDpi</maml:name>
<maml:description>
Expand Down Expand Up @@ -75463,6 +75499,18 @@ cells. This keeps existing-document editing simple without forcing callers back
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="False" position="named" aliases="None">
<maml:name>IgnorePermissionRestrictions</maml:name>
<maml:description>
<maml:para>After successful password authentication, explicitly ignore owner-imposed extraction restrictions.</maml:para>
</maml:description>
<command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue>
<dev:type>
<maml:name>SwitchParameter</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="None">
<maml:name>Language</maml:name>
<maml:description>
Expand Down Expand Up @@ -75565,6 +75613,18 @@ cells. This keeps existing-document editing simple without forcing callers back
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="False" position="named" aliases="None">
<maml:name>Password</maml:name>
<maml:description>
<maml:para>Password used to authenticate an encrypted PDF.</maml:para>
</maml:description>
<command:parameterValue required="false" variableLength="false">String</command:parameterValue>
<dev:type>
<maml:name>String</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="FilePath">
<maml:name>Path</maml:name>
<maml:description>
Expand All @@ -75589,6 +75649,18 @@ cells. This keeps existing-document editing simple without forcing callers back
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="False" position="named" aliases="None">
<maml:name>ReadOptions</maml:name>
<maml:description>
<maml:para>Optional bounded PDF parsing settings.</maml:para>
</maml:description>
<command:parameterValue required="false" variableLength="false">PdfLoadOptions</command:parameterValue>
<dev:type>
<maml:name>PdfLoadOptions</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="False" position="named" aliases="None">
<maml:name>RenderDpi</maml:name>
<maml:description>
Expand Down Expand Up @@ -143455,7 +143527,7 @@ This does not discover, bypass, or crack a missing password.</maml:para>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="False" position="named" aliases="None">
<maml:name>AllowDocumentFontEmbedding</maml:name>
<maml:description>
<maml:para>Allow embedding fonts stored in the workbook.</maml:para>
<maml:para>Allow embedding installed fonts selected by a trusted workbook. System-font embedding must also be enabled.</maml:para>
</maml:description>
<command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue>
<dev:type>
Expand Down Expand Up @@ -143858,7 +143930,7 @@ This does not discover, bypass, or crack a missing password.</maml:para>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="False" position="named" aliases="None">
<maml:name>AllowDocumentFontEmbedding</maml:name>
<maml:description>
<maml:para>Allow embedding fonts stored in the workbook.</maml:para>
<maml:para>Allow embedding installed fonts selected by a trusted workbook. System-font embedding must also be enabled.</maml:para>
</maml:description>
<command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue>
<dev:type>
Expand Down Expand Up @@ -153706,7 +153778,7 @@ Use -NoSave or omit -Path when a document object should be returned for further
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="False" position="named" aliases="None">
<maml:name>AllowDocumentFontEmbedding</maml:name>
<maml:description>
<maml:para>Allow embedding fonts stored in the presentation.</maml:para>
<maml:para>Allow embedding installed fonts selected by a trusted presentation. System-font embedding must also be enabled.</maml:para>
</maml:description>
<command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue>
<dev:type>
Expand Down Expand Up @@ -153959,7 +154031,7 @@ Use -NoSave or omit -Path when a document object should be returned for further
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="False" position="named" aliases="None">
<maml:name>AllowDocumentFontEmbedding</maml:name>
<maml:description>
<maml:para>Allow embedding fonts stored in the presentation.</maml:para>
<maml:para>Allow embedding installed fonts selected by a trusted presentation. System-font embedding must also be enabled.</maml:para>
</maml:description>
<command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue>
<dev:type>
Expand Down Expand Up @@ -158138,7 +158210,7 @@ Use -NoSave or omit -Path when a document object should be returned for further
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="False" position="named" aliases="None">
<maml:name>AllowDocumentFontEmbedding</maml:name>
<maml:description>
<maml:para>Allow embedding fonts stored in the Word document.</maml:para>
<maml:para>Allow embedding installed fonts selected by a trusted Word document. System-font embedding must also be enabled.</maml:para>
</maml:description>
<command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue>
<dev:type>
Expand Down Expand Up @@ -158389,7 +158461,7 @@ Use -NoSave or omit -Path when a document object should be returned for further
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="False" position="named" aliases="None">
<maml:name>AllowDocumentFontEmbedding</maml:name>
<maml:description>
<maml:para>Allow embedding fonts stored in the Word document.</maml:para>
<maml:para>Allow embedding installed fonts selected by a trusted Word document. System-font embedding must also be enabled.</maml:para>
</maml:description>
<command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue>
<dev:type>
Expand Down Expand Up @@ -199940,9 +200012,9 @@ cell inside a deck that already exists.</maml:para>
<maml:description>
<maml:para>Font size in points.</maml:para>
</maml:description>
<command:parameterValue required="false" variableLength="false">Int32</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Double</command:parameterValue>
<dev:type>
<maml:name>Int32</maml:name>
<maml:name>Double</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
Expand Down Expand Up @@ -200227,9 +200299,9 @@ cell inside a deck that already exists.</maml:para>
<maml:description>
<maml:para>Font size in points.</maml:para>
</maml:description>
<command:parameterValue required="false" variableLength="false">Int32</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Double</command:parameterValue>
<dev:type>
<maml:name>Int32</maml:name>
<maml:name>Double</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
Expand Down
2 changes: 1 addition & 1 deletion Docs/New-OfficeExcelPdfOptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Export-OfficeDocumentPdf -InputPath .\Report.xlsx -Path .\Report.pdf -ExcelOptio
## PARAMETERS

### -AllowDocumentFontEmbedding
Allow embedding fonts stored in the workbook.
Allow embedding installed fonts selected by a trusted workbook. System-font embedding must also be enabled.

```yaml
Type: SwitchParameter
Expand Down
2 changes: 1 addition & 1 deletion Docs/New-OfficePowerPointPdfOptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Export-OfficeDocumentPdf -InputPath .\Briefing.pptx -Path .\Briefing.pdf -PowerP
## PARAMETERS

### -AllowDocumentFontEmbedding
Allow embedding fonts stored in the presentation.
Allow embedding installed fonts selected by a trusted presentation. System-font embedding must also be enabled.

```yaml
Type: SwitchParameter
Expand Down
2 changes: 1 addition & 1 deletion Docs/New-OfficeWordPdfOptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Export-OfficeDocumentPdf -InputPath .\Report.docx -Path .\Report.pdf -WordOption
## PARAMETERS

### -AllowDocumentFontEmbedding
Allow embedding fonts stored in the Word document.
Allow embedding installed fonts selected by a trusted Word document. System-font embedding must also be enabled.

```yaml
Type: SwitchParameter
Expand Down
14 changes: 14 additions & 0 deletions Examples/Word/Example-Word-TemplatePdf.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
param(
[Parameter(Mandatory)]
[string] $InputPath,

[Parameter(Mandatory)]
[string] $OutputPath
)

Import-Module PSWriteOffice -ErrorAction Stop

# Use this policy for trusted templates whose requested fonts are installed on the host.
$options = New-OfficeWordPdfOptions -AllowSystemFontEmbedding -AllowDocumentFontEmbedding -IncludePageNumbers:$false
Export-OfficeDocumentPdf -InputPath $InputPath -Path $OutputPath -WordOptions $options -PdfConversionReportVariable report
$report.Warnings | Format-Table Code, Message
10 changes: 10 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,16 @@ $iWorkReport, $oneNoteReport | Select-Object HasLoss, Diagnostics

### Word

To export a trusted template with its installed fonts, enable document-font embedding and retain the conversion report:

```powershell
$options = New-OfficeWordPdfOptions -AllowSystemFontEmbedding -AllowDocumentFontEmbedding -IncludePageNumbers:$false
Export-OfficeDocumentPdf -InputPath .\Template.docx -Path .\Template.pdf -WordOptions $options -PdfConversionReportVariable report
$report.Warnings | Format-Table Code, Message
```

Both font permissions must be enabled to preserve installed template fonts. Balanced conversion substitutes standard PDF fonts for document-selected fonts unless document-font embedding is allowed; substitution can change table text widths, line breaks, and baselines. `-FontFamily` supplies a fallback for text whose document styles do not specify a family; it does not replace explicitly selected template fonts.

```powershell
New-OfficeWord -Path .\Report.docx {
WordSection {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public sealed class NewOfficeExcelPdfOptionsCommand : PSCmdlet {
[Parameter]
public SwitchParameter AllowSystemFontEmbedding { get; set; }

/// <summary>Allow embedding fonts stored in the workbook.</summary>
/// <summary>Allow embedding installed fonts selected by a trusted workbook. System-font embedding must also be enabled.</summary>
[Parameter]
public SwitchParameter AllowDocumentFontEmbedding { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public sealed class NewOfficePowerPointPdfOptionsCommand : PSCmdlet {
[Parameter]
public SwitchParameter AllowSystemFontEmbedding { get; set; }

/// <summary>Allow embedding fonts stored in the presentation.</summary>
/// <summary>Allow embedding installed fonts selected by a trusted presentation. System-font embedding must also be enabled.</summary>
[Parameter]
public SwitchParameter AllowDocumentFontEmbedding { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public sealed class NewOfficeWordPdfOptionsCommand : PSCmdlet {
[Parameter]
public SwitchParameter AllowSystemFontEmbedding { get; set; }

/// <summary>Allow embedding fonts stored in the Word document.</summary>
/// <summary>Allow embedding installed fonts selected by a trusted Word document. System-font embedding must also be enabled.</summary>
Comment thread
PrzemyslawKlys marked this conversation as resolved.
Resolved
[Parameter]
public SwitchParameter AllowDocumentFontEmbedding { get; set; }

Expand Down
14 changes: 14 additions & 0 deletions Tests/OfficePdfExport.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@ BeforeAll {
}

Describe 'Office document PDF exports' {
It 'preserves the caller font-embedding policy when constructing Word options' {
$balanced = New-OfficeWordPdfOptions
$balanced.ResourcePolicy.AllowSystemFontEmbedding | Should -BeTrue
Comment thread
PrzemyslawKlys marked this conversation as resolved.
Resolved
$balanced.ResourcePolicy.AllowDocumentFontEmbedding | Should -BeFalse

$template = New-OfficeWordPdfOptions -AllowSystemFontEmbedding -AllowDocumentFontEmbedding
$template.ResourcePolicy.AllowSystemFontEmbedding | Should -BeTrue
$template.ResourcePolicy.AllowDocumentFontEmbedding | Should -BeTrue

$restricted = New-OfficeWordPdfOptions -AllowDocumentFontEmbedding -AllowSystemFontEmbedding:$false
$restricted.ResourcePolicy.AllowDocumentFontEmbedding | Should -BeTrue
$restricted.ResourcePolicy.AllowSystemFontEmbedding | Should -BeFalse
}

It 'builds every format-specific PDF option through ordinary PowerShell parameters' {
$word = New-OfficeWordPdfOptions `
-Title 'Service report' `
Expand Down
Loading
Loading