Issue downloading a PDF file from Xojo cloud since v2022

Running the below code in debug mode allows me to download a PDF file (tested with Xojo versions since v2021 release 3.1).
Using the same code on Xojo cloud allows me to download the PDF when I use Xojo version 2021 3.1.
However, downloading does not work with the latest releases. The exception statement in the code reveals “Something really bad happened, but I don’t know what.”, so none of the used error options is recognized. Is this a bug or does anyone know how to adjust the code to get this working?

Note, downloading just TXT files works for any version both in debug and Xojo cloud.
You can try it with

And already, thanks for your help.

var DocumentPDF as PDFDocument
DocumentPDF = New PDFDocument(PDFDocument.PageSizes.A4)
DocumentPDF.Creator = "Test"
DocumentPDF.Author = "Test"
DocumentPDF.Keywords = "Test"
DocumentPDF.Title = "Test file downloads"
DocumentPDF.Subject = "Test file downloads"

var g as Graphics = DocumentPDF.Graphics
g.FontName = "Arial"
g.FontSize = 16
g.DrawingColor = kBlack

Const LeftMargin = 10
var LineVerticalPosition as integer = 25
g.DrawText("Test", LeftMargin, LineVerticalPosition)

If DocumentPDF <> Nil Then
  var PDFFolderItem as FolderItem
  PDFFolderItem = SpecialFolder.Temporary.Child("Test.PDF")
  DocumentPDF.Save (PDFFolderItem)
  Session.PDFFile = WebFile.Open (PDFFolderItem) //PDFFile is a property on the Session object
  Session.PDFFile.MIMEType = "application/pdf"
  Session.PDFFile.ForceDownload = True
  GoToURL (Session.PDFFile.URL)
end if

Exception err
  If err IsA TypeMismatchException Then
    MessageBox("Tried to retype an object!")
  ElseIf err IsA NilObjectException Then
    MessageBox("Tried to access a Nil object!")
  ElseIf err IsA InvalidArgumentException Then
  ElseIf err IsA PlatformNotSupportedException Then
  ElseIf err IsA UnsupportedOperationException Then
    MessageBox("Something really bad happened, but I don't know what.")
  End If

So another one is thrown. You should find out which one…

This may be happening because of a missing PDF lib. We’ll get that installed.

1 Like