Hide Preview Button Based On File Extension

So I have an interface with a grid that allows the user to preview or download a document. I want to hide the preview button if the file extension of the document is pdf.

Initially I was going to use showWhen but I wondered if a!foreach would also work?

I tried to use the document() function to get the extension, but I realized it only displays it and doesn't retrieve it.

This is what I have for the preview button so far. I haven't configured the download button yet.

a!buttonWidget(
  label: "",
  icon: "eye",
  tooltip: "View",
  value: true(),
  saveInto: {
    local!preview,
    a!save(local!selectedDocument, fv!row)
    
  }
)

  Discussion posts and replies are publicly visible