Creating PDF with JavaScript
I have created JavaScript bindings for boxes and glue. These bindings are made with goja. Let me show you an example:
I have created JavaScript bindings for boxes and glue. These bindings are made with goja. Let me show you an example:
Something that was a bit inconsistent for a while is variable assignments of element structures.
Take this snippet for example:
<SetVariable variable="myvar">
<Element name="Foo">
<Attribute name="attr" select="'foo1'"/>
</Element>
<Element name="Bar">
<Attribute name="attr" select="'bar1'"/>
</Element>
</SetVariable>
The speedata Publisher is built on top of LuaTeX, a typesetting software with a strong focus on typography. Therefore it inherits all the possibilities offered by the layout engine. One of the older features is the ability to stretch or shrink glyph widths on demand to allow even better line breaking.
TeX already uses the famous line breaking algorithm that optimizes the appearance of a full paragraph as a whole, not a line-by-line approach that might lead to large inter-word spacing.
The ability to stretch or shrink glyphs by a little amount can lead to many more possible line breaks and thus enhancing the overall visual outcome of a paragraph. The famous Gutenberg 42 line bible (B42) has a similar approach to line breaking.
Version 4.19.8 has a completely written module for creating tagged PDF for accessibility.
First, you need to set the output format to PDF/UA with
<PDFOptions format="PDF/UA" />
Tagged PDF also needs an outline of the structure of the document. See the previous blog entry for more details on tagged PDF. To summarize: you create an description of what is visible in the PDF. Each visible part gets tagged with a structure type (“this is a label for a table of contents link”, “this is a heading” and so on).
This sixth part of the mini-series about PDF is about tagged PDF, used in accessible PDF documents.
This part of the mini-series on PDF will be about metadata. Metadata is not visible in the document when printed, but only useful for curious human beings and some software that needs a PDF in a special format (like electronic invoices in the ZUGFeRD format). Metadata is always “about this document”, so it changes from document to document and must be applied individually.
Last week I have released the new stable version 4.18 with some big internal changes, which hopefully don’t affect your documents. Very intensive testing has been done and all test files (currently more than 220 and some bigger production documents) run fine with the new version.
This internal change is to make the new XML and XPath parser the default parser, which is a complete rewrite and is more robust than the old one.
PDF allows a lot of different interactive features such as web hyperlinks, jumping to a different location in the document, notes, video playback, JavaScript programs and many more. In this part I cover some of the basic features (bookmarks and annotations).
In the third part I cover vector graphics. You can also include PNG and JPEG images in the PDF, which will be covered in a later part of the PDF introduction.
This is part 2 of a mini-series on PDF.
Part 1 – PDF syntax and file structure
Part 2 – Fonts
Part 3 - Vector graphics
Part 4 - Interactive features
Part 5 - Metadata
Part 6 - Tagged PDF
Please note that all of these examples are created manually. If you wish to experiment with the examples, you can do so yourself. For more information, visit https://github.com/speedata/fixxref which provides a small program that supports manual PDF editing.
In the previous article in this series, I introduced the basic structure of a PDF file and how to create a PDF file using a text editor.
My goal in this post is to add some text to the PDF (using the included fonts). I should mention that you can find all the details in the PDF specification. There is one for 1.7 (recommended, very readable) and for 2.0 (register to download, few PDF viewers support 2.0 at the time of writing).
For this introduction, I don’t want to complicate things. So I will use one of the PDF viewer’s built-in fonts, a so-called “standard 14” font. These are Courier, Courier-Bold, Courier-BoldOblique, Courier-Oblique, Helvetica, Helvetica-Bold, Helvetica-BoldOblique, Helvetica-Oblique, Symbol, Times-Bold, Times-BoldItalic, Times-Italic, Times-Roman, ZapfDingbats.