diff --git a/Sources/PSWritePDF/Cmdlets/CmdletConvertPDFToText.cs b/Sources/PSWritePDF/Cmdlets/CmdletConvertPDFToText.cs index fb2f3b5..f22b029 100644 --- a/Sources/PSWritePDF/Cmdlets/CmdletConvertPDFToText.cs +++ b/Sources/PSWritePDF/Cmdlets/CmdletConvertPDFToText.cs @@ -12,8 +12,9 @@ namespace PSWritePDF.Cmdlets; [OutputType(typeof(string))] public class CmdletConvertPDFToText : PSCmdlet { - [Parameter(Mandatory = true)] - public string FilePath { get; set; } + [Parameter(Mandatory = true, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true)] + [Alias("FullName")] + public string FilePath { get; set; } = string.Empty; [Parameter] public int[] Page { get; set; } = Array.Empty(); diff --git a/Tests/Convert-PDFToText.Tests.ps1 b/Tests/Convert-PDFToText.Tests.ps1 index 3f18bef..e93aeff 100644 --- a/Tests/Convert-PDFToText.Tests.ps1 +++ b/Tests/Convert-PDFToText.Tests.ps1 @@ -4,4 +4,9 @@ Describe 'Convert-PDFToText' { $text = Convert-PDFToText -FilePath $file ($text -join "`n") | Should -Match 'Text 1' } + It 'accepts piped Get-ChildItem results' { + $files = Get-ChildItem -Path (Join-Path $PSScriptRoot 'Input') -Filter '*.pdf' + $text = $files | Convert-PDFToText + ($text -join "`n") | Should -Match 'Text 1' + } }