Getting the (pdf) preview of the first page of a word or excel document

documents are stored in a database file, they can be any type. but mainly pdf, jpeg or word-excel.
and I have to display the first page preview, even if no xxx-office app has been installed.
pdf ans jpeg are easy to display with a canvas backdrop picture.

command line parameters for write.exe

c:\Windows>write /p *.txt
c:\Windows>write /p *.doc

where *.doc or *.txt is the file for printing (if you have selected default printer to microsoft pdf it will print whole document to pdf).

The above method prints the whole document
to print just the first page you may need a windows script to do the job for you

you need this external program
to use and print the first page (page range) of every document you need

Public Function Thumbnail(extends f as FolderItem) As Picture
  ' returns the thumbnail of the given folderitem. *** MACOS ONLY ***
  Dim res As Picture
  #If TargetMacOS
    Dim s As New Shell
    Dim ft As FolderItem = SpecialFolder.Temporary
    Dim c As String = "qlmanage -t -s 1000 "+f.ShellPath+" -o "+ft.ShellPath
    s.Execute c
    If s.ExitCode=0 Then
      ft = ft.Child(f.Name+".png")
      res = Picture.Open( ft)
      Return res
    End If
End Function

for windows, chatGPT gives me that answer :

Dim wordApp As New WordApplication
wordApp.Visible = False
Dim outputFile As FolderItem = SpecialFolder.Desktop.Child("output.pdf")
wordApp.ActiveDocument.ExportAsFixedFormat(outputFile, 17) '17 is the enum value for wdExportFormatPDF

It looks like Xojo code and from what I understand you need Word installed on the Windows machine (long time since last time I used Xojo’s Office automation).

perhaps if you change wordApplication to WriteApplication (which is always present at windows installation it may work for you).