Re. Created PDF files

Discussions related to network, internet and socket programming; also to serial, parallel, Bluetooth, USB etc.
Hated Moron

Re. Created PDF files

Post by Hated Moron »

On 21/08/2022 08:39, svein svensson wrote (cross-posted from the Discussion Group):
No, pdflib wont work with BB4W, it's intended for BBCSDL since there is no printer support in SDL.
Whilst it is true that pdflib won't work fully in BBC BASIC for Windows, if you are using only FN_PLhardcopy (which I believe is what the OP is doing) it does appear to run without error, and generates a valid PDF file. The only thing wrong seems to be that the resulting PDF has an incorrect aspect ratio (it is 'stretched'), exactly as the OP has reported.

In fact I suspect that this is indeed a bug in pdflib, because if I run pdfdemo.bbc in BBC BASIC for SDL 2.0, but delete the lines which set the initial window size, that too generates a PDF with the wrong aspect ratio! So I'm suspicious that FN_PLhardcopy() is misbehaving in not preserving the aspect ratio.

My understanding was that FN_PLhardcopy() is designed to work like *HARDCOPY in BB4W (with no parameters), which by default centres the window on the printed page rather than stretching it. If you want stretching you can achieve that by specifying the parameters explicitly.
Or (as i found out today) simply use the inbuilt 'Microsoft Print to PDF'.
Indeed. The code to create a PDF version of what's displayed in BB4W is extremely simple:

Code: Select all

      *PRINTER Microsoft Print to PDF
      *HARDCOPY
      VDU 2,1,12,3
svein
Posts: 58
Joined: Tue 03 Apr 2018, 19:34

Re: Re. Created PDF files

Post by svein »

that the resulting PDF has an incorrect aspect ratio (it is 'stretched')
In fact I suspect that this is indeed a bug in pdflib
No, it's not a bug, it's a result of hardcoding a single static page.
FN_PLhardcopy copies the entire window to an A4 size.
Therefore the window must initially be A4 size (596,842 pixels) or else stretching one way or another will occur.
This only applies to FN_PLhardcopy, one can use FN_PLcreatepdf with any window size. The onscreen preview will probably be messed up, but one can always just open the created PDF file to see the result.

I am in the process of rewriting FN_PLhardcopy to function exactly as described in the manual (*HARDCOPY), so don't write anything important with the current version.

This will then remove the need for an initial A4 window size.

Svein