Current state of PDF compat?

Talk about code development, features, specific bugs, enhancements, patches, and similar things.
Forum rules
Please keep everything here strictly on-topic.
This board is meant for Pale Moon source code development related subjects only like code snippets, patches, specific bugs, git, the repositories, etc.

This is not for tech support! Please do not post tech support questions in the "Development" board!
Please make sure not to use this board for support questions. Please post issues with specific websites, extensions, etc. in the relevant boards for those topics.

Please keep things on-topic as this forum will be used for reference for Pale Moon development. Expect topics that aren't relevant as such to be moved or deleted.
User avatar
Bilbo47
Lunatic
Lunatic
Posts: 262
Joined: 2017-11-18, 04:24

Current state of PDF compat?

Unread post by Bilbo47 » 2024-07-28, 21:29

How does PDF display work these days?

A very old post seemed to say PDF was compiled in to the browser, so one assumes no Add-on nor external package was needed. However File - Open - PDF works by launching a plugin DLL provided by a separate PDF program here. Other browsers here use various other methods to display PDF.

Problem: a bank-like site provides its statements by generating a PDF on the fly. Except the generation is done by jsPDF, which runs in the browser and not on the server. That is insane to me. When the page downloads a javascript from a CDN or central server, that's a recipe for a supply-chain attack against all financial data served by this site.

Anyway the site's PDF functionality fails in my preferred browsers, starting with PM. Using a very simple script, all browsers here, except for two, generate PDFs as expected. PM 33.2.1/64 fails hardest, and SeaMonkey 2.53.13 is the runner-up. The code is like

Code: Select all

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"   ></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js" ></script>

const { jsPDF } = window.jspdf                                      ; //
var    objPdf   = new jsPDF( { format: [ 8.5, 11 ], unit: "in", } ) ; // instantiate PDF object as Letter size
In javascript debugger, the instantiate line gives "TypeError: can't convert undefined to object", probably on a call to RequireObjectCoercible( ). Not sure what exactly is failing, and why it fails in only two browsers. In SM, the code goes farther, but gets stuck with a status line of "Read cdnjs.cloudflare.com" and never finishes loading:

Code: Select all

strPdf = objPdf.output( 'pdfobjectnewwindow' ) ; // emit PDF to new browser window/tab

Daikun
Lunatic
Lunatic
Posts: 459
Joined: 2013-12-13, 20:54
Location: California

Re: Current state of PDF compat?

Unread post by Daikun » 2024-07-28, 23:38

Native PDF use was disabled in PM years ago.
If you want to view PDFs in the browser, just install PDF Viewer.

User avatar
adoxa
Lunatic
Lunatic
Posts: 254
Joined: 2019-03-16, 13:26
Location: Qld, Aus.
Contact:

Re: Current state of PDF compat?

Unread post by adoxa » 2024-07-29, 05:55

Seems to work fine for me (Basilisk 2024.05.11, allowing the popup, in a new profile [something in my main profile didn't like the new window, didn't bother looking into it]).

Code: Select all

<html>
<meta charset="utf-8"/>
<head><title>PDF test</title></head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"   ></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js" ></script>
<script>
const { jsPDF } = window.jspdf                                      ; //
var    objPdf	= new jsPDF( { format: [ 8.5, 11 ], unit: "in", } ) ; // instantiate PDF object as Letter size
objPdf.text("A line of text.", 1, 1);
objPdf.output('pdfobjectnewwindow');
</script>
</body>
</html>
Attachments
pdftest.png

User avatar
moonbat
Knows the dark side
Knows the dark side
Posts: 5261
Joined: 2015-12-09, 15:45
Contact:

Re: Current state of PDF compat?

Unread post by moonbat » 2024-07-29, 06:24

Maybe it is built into Basilisk, since that is based on FF 52. I tried 'window.jspdf' in the scratchpad in Pale Moon and it shows up as undefined.
"One hosts to look them up, one DNS to find them and in the darkness BIND them."

Image
KDE Neon on a Slimbook Excalibur (Ryzen 7 8845HS, 64 GB RAM)
AutoPageColor|PermissionsPlus|PMPlayer|Pure URL|RecordRewind|TextFX

User avatar
adoxa
Lunatic
Lunatic
Posts: 254
Joined: 2019-03-16, 13:26
Location: Qld, Aus.
Contact:

Re: Current state of PDF compat?

Unread post by adoxa » 2024-07-29, 08:15

I expect it's added by the script that loads it...

User avatar
Bilbo47
Lunatic
Lunatic
Posts: 262
Joined: 2017-11-18, 04:24

Re: Current state of PDF compat?

Unread post by Bilbo47 » 2024-07-31, 15:36

To clarify, this post is not about viewing - it is about generating. The problem I see is that some dumb sites want the browser's JS engine to execute downloaded code to generate a PDF. Everything after that is beside the point. When the code calls something not provided by that browser's JS system then the generating fails. What is it about PM's JS that fails when basically all other browsers succeed in creating the PDF? Yes it worked in Basilisk before posting. Should that be a clue about whether it should also work in PM?

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 36384
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

Re: Current state of PDF compat?

Unread post by Moonchild » 2024-07-31, 16:07

I just had a peek to see what this is all about.
http://raw.githack.com/MrRio/jsPDF/master/index.html seems to be the library they want to use. That works just fine in Pale Moon as they only seem to require ES2015 compatibility (which we have, and then some), and the demo on github works just fine.
I'm not sure what the issue is off-hand with that particular site but it doesn't seem to be an issue with jsPDF or Pale Moon's capability to generate PDFs with it, but rather some surrounding code that makes it not be loaded/initialized correctly on that site.
"A programmer is someone who solves a problem you didn't know you had, in a way you don't understand." -- unknown
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

User avatar
Bilbo47
Lunatic
Lunatic
Posts: 262
Joined: 2017-11-18, 04:24

Re: Current state of PDF compat?

Unread post by Bilbo47 » 2024-07-31, 17:10

Confirmed not a PM failure; the tiny test and the real site both work fine in a blank profile. Will track down the offending add-on or setting or whatever.

Funny thing: the same PDF generated in different browsers ends up with different filesizes and different fonts. Again the whole idea of "HTML5 client-side PDF generation" makes zero sense for important data, *because* the outputs will vary with the browser.

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 36384
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

Re: Current state of PDF compat?

Unread post by Moonchild » 2024-07-31, 17:25

Bilbo47 wrote:
2024-07-31, 17:10
Funny thing: the same PDF generated in different browsers ends up with different filesizes and different fonts. Again the whole idea of "HTML5 client-side PDF generation" makes zero sense for important data, *because* the outputs will vary with the browser.
Completely agree. depending on the browser, the PDF (which is supposed to be a locked-in version for printing and display) may even end up with completely unintended layout or mangled content depending on the metrics of the browser engine, OS, and what not. It's taking "bandwidth optimization" too far. Just host the PDFs on the server (or generate them there with known-good parameters).
"A programmer is someone who solves a problem you didn't know you had, in a way you don't understand." -- unknown
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

User avatar
moonbat
Knows the dark side
Knows the dark side
Posts: 5261
Joined: 2015-12-09, 15:45
Contact:

Re: Current state of PDF compat?

Unread post by moonbat » 2024-08-01, 00:27

First time I've heard of generating PDFs within the browser :shock:
More twisting and torturing what was originally meant to be a remote document viewer, no more.
"One hosts to look them up, one DNS to find them and in the darkness BIND them."

Image
KDE Neon on a Slimbook Excalibur (Ryzen 7 8845HS, 64 GB RAM)
AutoPageColor|PermissionsPlus|PMPlayer|Pure URL|RecordRewind|TextFX

User avatar
jobbautista9
Keeps coming back
Keeps coming back
Posts: 855
Joined: 2020-11-03, 06:47
Location: Philippines
Contact:

Re: Current state of PDF compat?

Unread post by jobbautista9 » 2024-08-01, 02:36

Off-topic:
I wonder why they even need it to be PDF, whether generated server-side or client-side. A bank statement could probably just be a simple HTML document that is designed to be printable. If a featured article in Wikipedia can look decent in a print preview, then so can a bank statement! :coffee:
Image

merry mimas

XUL add-ons developer. You can find a list of add-ons I manage at http://rw.rs/~job/software.html.

Mima avatar by 絵虎. Pixiv post: https://www.pixiv.net/en/artworks/15431817

Image

vannilla
Moon Magic practitioner
Moon Magic practitioner
Posts: 2261
Joined: 2018-05-05, 13:29

Re: Current state of PDF compat?

Unread post by vannilla » 2024-08-01, 14:59

jobbautista9 wrote:
2024-08-01, 02:36
Off-topic:
I wonder why they even need it to be PDF, whether generated server-side or client-side. A bank statement could probably just be a simple HTML document that is designed to be printable. If a featured article in Wikipedia can look decent in a print preview, then so can a bank statement! :coffee:
Off-topic:
The main reason is that people have learned that PDF = printable, "web site" = read-only.
I'm aware of all those jokes about people printing web pages and faxing them to their nieces and nephews instead of sending a link via instant messaging, but that's old history.
The fact that desktop browsers make the "print" option somewhat hidden in hamburger menus and submenus and mobile devices being obviously unable to print anything let alone a web page, has given rise to the belief that to print a document you need a special file in this case a PDF.
If one were to build a dedicated UI to allow people to print a web page by pressing a button on screen (e.g. calling window.print() from javascript) then people can be fooled, but this specific website decided to offload all of it to the browser's default PDF viewer.

User avatar
moonbat
Knows the dark side
Knows the dark side
Posts: 5261
Joined: 2015-12-09, 15:45
Contact:

Re: Current state of PDF compat?

Unread post by moonbat » 2024-08-01, 23:02

Off-topic:
vannilla wrote:
2024-08-01, 14:59
If one were to build a dedicated UI to allow people to print a web page by pressing a button on screen
There's already a print button one can add to the toolbar, maybe this should be on it by default.
"One hosts to look them up, one DNS to find them and in the darkness BIND them."

Image
KDE Neon on a Slimbook Excalibur (Ryzen 7 8845HS, 64 GB RAM)
AutoPageColor|PermissionsPlus|PMPlayer|Pure URL|RecordRewind|TextFX

User avatar
suzyne
Astronaut
Astronaut
Posts: 546
Joined: 2023-06-28, 22:43
Location: Australia

Re: Current state of PDF compat?

Unread post by suzyne » 2024-08-02, 00:41

Off-topic:
vannilla wrote:
2024-08-01, 14:59
The fact that desktop browsers make the "print" option somewhat hidden in hamburger menus
Would it be fair to think that with the widespread use of apps on phones that most people have been conditioned to no longer expect every option and action to be visible at all times, and that the idea that items in hamburger menus (even on the desktop) are relatively hidden is also "old history"?
Laptop 1: Windows 10 64-bit, i7 @ 2.80GHz, 16GB, NVIDIA GeForce MX450.
Laptop 2: Windows 10 32-bit, Atom Z3735F @ 1.33GHz, 2GB, Intel HD Graphics.

User avatar
moonbat
Knows the dark side
Knows the dark side
Posts: 5261
Joined: 2015-12-09, 15:45
Contact:

Re: Current state of PDF compat?

Unread post by moonbat » 2024-08-02, 01:50

suzyne wrote:
2024-08-02, 00:41
Would it be fair to think that with the widespread use of apps on phones
More like the developer and UX designers' decision to impose the mobile focused UI with all its restrictions everywhere just to save money having to maintain two different interfaces. Even when in the case of websites, it is perfectly possible to serve device optimized layouts using HTML5 & CSS. End users never had a say in any of this.
"One hosts to look them up, one DNS to find them and in the darkness BIND them."

Image
KDE Neon on a Slimbook Excalibur (Ryzen 7 8845HS, 64 GB RAM)
AutoPageColor|PermissionsPlus|PMPlayer|Pure URL|RecordRewind|TextFX

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 36384
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

Re: Current state of PDF compat?

Unread post by Moonchild » 2024-08-02, 01:59

Off-topic:
moonbat wrote:
2024-08-02, 01:50
Even when in the case of websites, it is perfectly possible to serve device optimized layouts using HTML5 & CSS.
That was the whole point of pushing for "responsive design" -- remember that? @media queries in CSS, flex boxes (yes it was meant for that, not as a pseudo table), etc. etc.
"A programmer is someone who solves a problem you didn't know you had, in a way you don't understand." -- unknown
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

User avatar
moonbat
Knows the dark side
Knows the dark side
Posts: 5261
Joined: 2015-12-09, 15:45
Contact:

Re: Current state of PDF compat?

Unread post by moonbat » 2024-08-02, 02:04

Is responsive design really that hard to implement for it to be ignored? As I understand you don't even have to serve up a separate set of CSS and can easily figure out the device in use and adjust the page accordingly.
"One hosts to look them up, one DNS to find them and in the darkness BIND them."

Image
KDE Neon on a Slimbook Excalibur (Ryzen 7 8845HS, 64 GB RAM)
AutoPageColor|PermissionsPlus|PMPlayer|Pure URL|RecordRewind|TextFX

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 36384
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

Re: Current state of PDF compat?

Unread post by Moonchild » 2024-08-02, 02:22

No, my point was that they pushed really hard for browsers to implement all this stuff for it, adding a hell of a lot of complexity and dev pressure, only to then barely use it and use it for the wrong thing anyway. I'm guessing part of this was because of "designers" wanting to push "uniformity" and/or just getting lazy.
"A programmer is someone who solves a problem you didn't know you had, in a way you don't understand." -- unknown
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

vannilla
Moon Magic practitioner
Moon Magic practitioner
Posts: 2261
Joined: 2018-05-05, 13:29

Re: Current state of PDF compat?

Unread post by vannilla » 2024-08-02, 07:45

moonbat wrote:
2024-08-02, 02:04
Is responsive design really that hard to implement for it to be ignored? As I understand you don't even have to serve up a separate set of CSS and can easily figure out the device in use and adjust the page accordingly.
Some particularly ill-designed layouts can be difficult no matter what, but in general it's not that hard.
In fact, as time goes on things are actually becoming easier, but at the same time most websites are actually not handled in-house but offshored to agencies or freelancers who estimate that "pure CSS" is always not worth the time even when it might be the better solution overall.

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 36384
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

Re: Current state of PDF compat?

Unread post by Moonchild » 2024-08-02, 08:21

Off-topic:
For the record, this forum has responsive design. resize the browser window horizontally ;)
"A programmer is someone who solves a problem you didn't know you had, in a way you don't understand." -- unknown
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

Post Reply