class PdfDocument in Switch 25.11

Post Reply
cotto
Newbie
Posts: 3
Joined: Thu Aug 03, 2023 1:49 pm

class PdfDocument in Switch 25.11

Post by cotto »

Hello and a happy new year!

I updated Switch from 2024 Fall to 25.11.
After that, Switch throws "ReferenceError: PdfDocument is not defined"
Updating the devDependencies from 'v24.0.2-final-updated.tar.gz' to 'v24.1.1-final.tar.gz' didn't solve the problem.
Is there anything I need to be aware of?

Thanks in advance!
freddyp
Advanced member
Posts: 1171
Joined: Thu Feb 09, 2012 3:53 pm

Re: class PdfDocument in Switch 25.11

Post by freddyp »

Modifying the typings file was a first and correct thing to do, but there is another thing.

The manifest.xml file in the script folder specifies the Switch version with which the script folder was created. When Switch runs a script it uses that information to choose which NodeJS version to use. What is probably happening here is that a NodeJS version is being used in which the PdfDocument class was not yet available.

The PdfDocument class was already available in 2024 Fall, but if my suspicion is correct, the script folder is older than that.
cotto
Newbie
Posts: 3
Joined: Thu Aug 03, 2023 1:49 pm

Re: class PdfDocument in Switch 25.11

Post by cotto »

I made the recommended changes, but the problem still occurs.
I then ran a few tests.
I use the switch types in my own modules, which are also imported into the main project.
When I comment out the methods from these modules that use the PdfDocument class, the script works without the changes.
Does this mean that typing in separate modules no longer works?
Or is a special configuration required?
freddyp
Advanced member
Posts: 1171
Joined: Thu Feb 09, 2012 3:53 pm

Re: class PdfDocument in Switch 25.11

Post by freddyp »

There are quite some settings involved in the package.json, tsconfig.json and the code itself. It may be just one of the settings that is wrong, but there is only one way to tell and that is by looking at the whole picture. Please report this to support and provide the script folder and the package so we can investigate. We will report our findings here as well so other users can learn from it.
cotto
Newbie
Posts: 3
Joined: Thu Aug 03, 2023 1:49 pm

Re: class PdfDocument in Switch 25.11

Post by cotto »

Thanks, I have done that.
Post Reply