Welcome!
My guess is, this is because the webviewer component is not able to store files...
it might be possible using the custom webviewer extension...
however my suggestion is to use an extension to create the pdf file directly without using JavaScript...
you could try
alternatively
-
Create PDF Extension Text to PDF | HTML to PDF | Webpage to PDF by Hitesh and DeveloperLeo (100 Rs or 5 USD)
-
Advance PDF Creator by Shreya to encrypt/decrypt PDF, image to PDF, webview to PDF etc
links taken from the extensions directory App Inventor Extensions | Pura Vida Apps
Taifun