I have a stack which generates a PDF report.
Printing is opened using
set the printPaperOrientation to "landscape"
set the printPaperScale to 0.60
open printing to pdf <filename>
Each page is made by filling in various fields, and setting the data for a
graph widget; then using
print card from <point> to <point> into <rect>
If I simply use the IDE menus to set page setup to landscape/60%, and Print
Card to Preview or Save to PDF, it works fine.
But when the PDF is generated by the above code, text in right-aligned fields
are not aligned neatly, but with a ragged edge. The effect is what I'd expect
if the text had been measured with one font/size, but displayed with another.
When I started digging, it started to look as though there may be two
different code paths.
The Dictionary entry for open printing doesn't mention the "... to pdf
<filename>" syntax. Although not linked from the entry for "open printing",
the Dictionary does have an entry for the "printerOutput" property, which it
says can be given a few different values, including
file - <filename> : output to the given file. The format of the file depends
on the platform:
preview - output to print preview (only supported on Mac OS X).
That's sic: there's nothing after "depends on the platform:" except for the
next option, "preview".
With printerOutput set to "preview" the document is opened in the mac Preview
app... and the right-aligned text is indeed right-aligned.
The "file" option works, although the Dictionary entry is unhelpful in
relation to the syntax: the format needs to be "file:<filename>" (clue found
in User Guide). Anything else is either an error, or nothing is produced. With
that format, if the filename ends in .pdf, a PDF is produced, but the document
is always portrait; if the code specified landscape, the output is squeezed
(which I take to mean that the printPaperRect lied).
So it seems that, at least on macOS, there are two routes for printing to PDF,
with exciting variations:
a) open printing to pdf <filename>
This route generates a PDF file on disk; printPaperOrientation and
printPaperScale are both honoured; but there are text alignment problems.
b) set printerOutput to "preview" ; open printing
This route generates a temporary PDF opened in the Preview app; right aligned
text is correct; printPaperOrientation is honoured; but printPaperScale is
ignored.
c) set printerOutput to "file:<filename>" ; open printing
This route generates a PDF file on disk; printPaperOrientation doesn't affect
the document orientation, but does affect the printPaperRect; printPaperScale
is ignored. But right-aligned text is fine!
As an extra detail, another undocumented (at least in the Dictionary) feature
which I evidently discovered somewhere sometime, is that you can use the syntax
open printing to pdf <filename> with options <array>
to set attributes of the PDF such as Title, Author and so on.
(Attempting to use the syntax
open printing with options <array>
is an error, however.)
It's all a bit confusing!!
Anyway, this email got longer as I continued to investigate. All I really want
is to figure out a way to get my nice right-aligned text right. Is it perhaps
possibly that if I started with a different font or font size, it would render
the same way in the PDF as it does on screen?
Any tips, lore, suggestions welcome.
Ben
_______________________________________________
use-livecode mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode