Powershell to extract renditions

There may be a way to extract all PDF renditions for a selection of Records via the native client but I do not know how to do it.  When I have powershell I don't worry about the client, I just write a script, like this one...

Add-Type -Path "c:\trunk\AnyCPU\Debug\HP.HPTRIM.SDK.dll"
$database = New-Object HP.HPTRIM.SDK.Database
$database.Id = "I1"
$database.WorkgroupServerName = "local"

$recordSearch = New-Object HP.HPTRIM.SDK.TrimMainObjectSearch($database, [HP.HPTRIM.SDK.BaseObjectTypes]::Record)

foreach ($record in $recordSearch) {
    foreach ($rendition in $record.ChildRenditions) {
        if ($rendition.TypeOfRendition -eq [HP.HPTRIM.SDK.RenditionType]::Longevity) {
            $extracted = $rendition.Extract("c:\MyTest\" + $record.Uri + "-" +$rendition.Uri + "." +$rendition.Extension, $false)
            Write-Host "Extracted: " $extracted



  • I name the PDF file using both the Record and Rendition URI to both associate the file with the Record and also to allow for the fact that a Record may have multiple PDF renditions.
  • I would have used the record number for the file name except that record numbers may contain slashes which would break in a file name.
  • Your SDK path will be different to mine, most probably under Program Files instead of my Debug directory.