Skip to content
1 change: 1 addition & 0 deletions openpdf-html/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ This project is licensed under the **GNU Lesser General Public License (LGPL)**.
- Seamless integration with OpenPDF
- Modular architecture for easier maintenance and extension
- API compatible with Flying saucer, except package names are org.openpdf instead of org.xhtmlrenderer.
- Support of glyph layout for [DIN 91379](https://en.wikipedia.org/wiki/DIN_91379) and complex scripts, see [Wiki](https://github.com/LibrePDF/OpenPDF/wiki/Accents,-DIN-91379,-non-Latin-scripts).

### htmlunit-neko Parser Integration

Expand Down
13 changes: 13 additions & 0 deletions openpdf-html/src/main/java/org/openpdf/pdf/ITextRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package org.openpdf.pdf;

import org.openpdf.text.DocumentException;
import org.openpdf.text.pdf.GlyphLayoutManager;
import org.openpdf.text.pdf.PdfPageEvent;
import org.openpdf.text.pdf.PdfWriter;
import org.jspecify.annotations.Nullable;
Expand Down Expand Up @@ -121,6 +122,9 @@ public class ITextRenderer {
@Nullable
private PDFCreationListener _listener;

@Nullable
private GlyphLayoutManager glyphLayoutManager;

public ITextRenderer(File file) throws IOException {
this();
File parent = file.getAbsoluteFile().getParentFile();
Expand Down Expand Up @@ -393,6 +397,11 @@ public void createPDF(OutputStream os, boolean finish, int initialPageNo) throws
writer.setEncryption(_pdfEncryption.getUserPassword(), _pdfEncryption.getOwnerPassword(),
_pdfEncryption.getAllowedPrivileges(), _pdfEncryption.getEncryptionType());
}

if (glyphLayoutManager != null) {
writer.setGlyphLayoutManager(glyphLayoutManager);
}

_pdfDoc = doc;
_writer = writer;

Expand Down Expand Up @@ -595,6 +604,10 @@ public List<PagePosition> findPagePositionsByID(Pattern pattern) {
return _outputDevice.findPagePositionsByID(newLayoutContext(), pattern);
}

public void setGlyphLayoutManager(GlyphLayoutManager glyphLayoutManager) {
this.glyphLayoutManager = glyphLayoutManager;
}


private static final class NullUserInterface implements UserInterface {
@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* This file is part of the OpenPDF HTML module.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* Volker Kunert 2026
*/
package org.openpdf.pdf;

import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Objects;
import javax.xml.parsers.DocumentBuilderFactory;
import org.openpdf.text.pdf.GlyphLayoutFontManager;
import org.openpdf.text.pdf.GlyphLayoutManager;

public class GlyphLayoutHtmlExample {

public static void main(String[] args) {
var glyphLayoutHtmlExample = new GlyphLayoutHtmlExample();
try {
glyphLayoutHtmlExample.test();
} catch (Exception e) {
e.printStackTrace();
}
}

public void test() throws Exception {
var htmlFilename = "GlyphLayoutHtmlExample.html";
var inputStream = this.getClass().getResourceAsStream(htmlFilename);
var documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
var document = documentBuilder.parse(inputStream);

var glyphLayoutManager = new GlyphLayoutManager();
var fontResolver = new ITextFontResolver();

loadFont(glyphLayoutManager, fontResolver, "Arimo-Regular.ttf", 12.0f,
"fonts/arimo/Arimo-Regular.ttf");
loadFont(glyphLayoutManager, fontResolver, "Arimo-Bold.ttf", 12.0f,
"fonts/arimo/Arimo-Bold.ttf");

var pdfFilename = "GlyphLayoutHtmlExample.pdf";
try (var outputStream = new FileOutputStream(pdfFilename)) {
var renderer = new ITextRenderer(fontResolver);
renderer.setDocument(document);
renderer.setGlyphLayoutManager(glyphLayoutManager);
renderer.layout();
renderer.createPDF(outputStream);
}
System.out.println("PDF created: " + pdfFilename);
}

private void loadFont(GlyphLayoutManager glyphLayoutManager, ITextFontResolver fontResolver, String fontName,
float fontSize, String fontResourcePath) throws IOException, GlyphLayoutFontManager.FontLoadException {
var fontUrl = this.getClass().getResource(fontResourcePath);
Objects.requireNonNull(fontUrl, "Font not found: " + fontResourcePath);
try (var fontStream = fontUrl.openStream()) {
var font = glyphLayoutManager.loadFont(fontName, fontStream, fontSize);
fontResolver.addFont(font.getBaseFont(), fontUrl.getFile(), null);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<html lang="en">
<head>
<meta charset="utf-8"/>
<style>
@page {
size: A4;
margin: 2cm;
}
body {
font-family: Arimo, sans-serif;
font-size: 12pt;
}
</style>
<title>Letters from DIN 91379 with OpenPDF-html</title>
</head>
<body>
<h1>Letters from DIN 91379 with OpenPDF-html</h1>

The list of letters from <a href="https://en.wikipedia.org/wiki/DIN_91379">DIN 91379</a> (see
<a href="https://github.com/String-Latin/DIN-91379-Characters-and-Sequences/blob/main/latin_letters_1.3.txt">
latin_letters_1.3.txt</a>) is rendered with <a
href="https://github.com/LibrePDF/OpenPDF/tree/master/openpdf-html">OpenPDF-html</a> using
<a href="https://github.com/LibrePDF/OpenPDF/wiki/Accents,-DIN-91379,-non-Latin-scripts">GlyphLayoutManager</a> and
the
<a href="https://github.com/googlefonts/Arimo">Arimo</a> font.

<h2>bll; Latin Letters (normative)</h2>
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
a b c d e f g h i j k l m n o p q r s t u v w x y z
À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï Ð Ñ Ò Ó Ô Õ Ö Ø Ù Ú
Û Ü Ý Þ ß à á â ã ä å æ ç è é ê ë ì í î ï ð ñ ò ó ô
õ ö ø ù ú û ü ý þ ÿ Ā ā Ă ă Ą ą Ć ć Ĉ ĉ Ċ ċ Č č Ď ď
Đ đ Ē ē Ĕ ĕ Ė ė Ę ę Ě ě Ĝ ĝ Ğ ğ Ġ ġ Ģ ģ Ĥ ĥ Ħ ħ Ĩ ĩ
Ī ī Ĭ ĭ Į į İ ı IJ ij Ĵ ĵ Ķ ķ ĸ Ĺ ĺ Ļ ļ Ľ ľ Ŀ ŀ Ł ł Ń
ń Ņ ņ Ň ň ʼn Ŋ ŋ Ō ō Ŏ ŏ Ő ő Œ œ Ŕ ŕ Ŗ ŗ Ř ř Ś ś Ŝ ŝ
Ş ş Š š Ţ ţ Ť ť Ŧ ŧ Ũ ũ Ū ū Ŭ ŭ Ů ů Ű ű Ų ų Ŵ ŵ Ŷ ŷ
Ÿ Ź ź Ż ż Ž ž Ƈ ƈ Ə Ɨ Ơ ơ Ư ư Ʒ Ǎ ǎ Ǐ ǐ Ǒ ǒ Ǔ ǔ Ǖ ǖ
Ǘ ǘ Ǚ ǚ Ǜ ǜ Ǟ ǟ Ǣ ǣ Ǥ ǥ Ǧ ǧ Ǩ ǩ Ǫ ǫ Ǭ ǭ Ǯ ǯ ǰ Ǵ ǵ Ǹ
ǹ Ǻ ǻ Ǽ ǽ Ǿ ǿ Ȓ ȓ Ș ș Ț ț Ȟ ȟ ȧ Ȩ ȩ Ȫ ȫ Ȭ ȭ Ȯ ȯ Ȱ ȱ
Ȳ ȳ ə ɨ ʒ Ḃ ḃ Ḇ ḇ Ḋ ḋ Ḍ ḍ Ḏ ḏ Ḑ ḑ ḗ Ḝ ḝ Ḟ ḟ Ḡ ḡ Ḣ ḣ
Ḥ ḥ Ḧ ḧ Ḩ ḩ Ḫ ḫ ḯ Ḱ ḱ Ḳ ḳ Ḵ ḵ Ḷ ḷ Ḻ ḻ Ṁ ṁ Ṃ ṃ Ṅ ṅ Ṇ
ṇ Ṉ ṉ Ṓ ṓ Ṕ ṕ Ṗ ṗ Ṙ ṙ Ṛ ṛ Ṟ ṟ Ṡ ṡ Ṣ ṣ Ṫ ṫ Ṭ ṭ Ṯ ṯ Ẁ
ẁ Ẃ ẃ Ẅ ẅ Ẇ ẇ Ẍ ẍ Ẏ ẏ Ẑ ẑ Ẓ ẓ Ẕ ẕ ẖ ẗ ẞ Ạ ạ Ả ả Ấ ấ
Ầ ầ Ẩ ẩ Ẫ ẫ Ậ ậ Ắ ắ Ằ ằ Ẳ ẳ Ẵ ẵ Ặ ặ Ẹ ẹ Ẻ ẻ Ẽ ẽ Ế ế
Ề ề Ể ể Ễ ễ Ệ ệ Ỉ ỉ Ị ị Ọ ọ Ỏ ỏ Ố ố Ồ ồ Ổ ổ Ỗ ỗ Ộ ộ
Ớ ớ Ờ ờ Ở ở Ỡ ỡ Ợ ợ Ụ ụ Ủ ủ Ứ ứ Ừ ừ Ử ử Ữ ữ Ự ự Ỳ ỳ
Ỵ ỵ Ỷ ỷ Ỹ ỹ
<h3>Sequences</h3>
A̋ C̀ C̄ C̆ C̈ C̕ C̣ C̦ C̨̆ D̂ F̀ F̄ G̀ H̄ H̦ H̱ J́ J̌ K̀ K̂ K̄ K̇ K̕ K̛ K̦ K͟H
K͟h L̂ L̥ L̥̄ L̦ M̀ M̂ M̆ M̐ N̂ N̄ N̆ N̦ P̀ P̄ P̕ P̣ R̆ R̥ R̥̄ S̀ S̄ S̛̄ S̱ T̀ T̄
T̈ T̕ T̛ U̇ Z̀ Z̄ Z̆ Z̈ Z̧ a̋ c̀ c̄ c̆ c̈ c̕ c̣ c̦ c̨̆ d̂ f̀ f̄ g̀ h̄ h̦ j́ k̀
k̂ k̄ k̇ k̕ k̛ k̦ k͟h l̂ l̥ l̥̄ l̦ m̀ m̂ m̆ m̐ n̂ n̄ n̆ n̦ p̀ p̄ p̕ p̣ r̆ r̥ r̥̄
s̀ s̄ s̛̄ s̱ t̀ t̄ t̕ t̛ u̇ z̀ z̄ z̆ z̈ z̧ Ç̆ Û̄ ç̆ û̄ ÿ́ Č̕ Č̣ č̕ č̣ ē̍ Ī́ ī́
ō̍ Ž̦ Ž̧ ž̦ ž̧ Ḳ̄ ḳ̄ Ṣ̄ ṣ̄ Ṭ̄ ṭ̄ Ạ̈ ạ̈ Ọ̈ ọ̈ Ụ̄ Ụ̈ ụ̄ ụ̈
<h2>bnlreq; Non-Letters N1 (normative)</h2>
' , - . ` ~ ¨ ´ · ʹ ʺ ʾ ʿ ˈ ˌ ’ ‡
<h2>bnl; Non-Letters N2 (normative)</h2>
<![CDATA[! " # $ % & ( ) * + / 0 1 2 3 4 5 6 7 8 9 : ; < = >
? @ [ \ ] ^ _ { | } ¡ ¢ £ ¥ § © ª « ¬ ® ¯ ° ± ² ³ µ
¶ ¹ º » ¿ × ÷ €]]>
<h2>bnlopt; Non-Letters N3 (normative)</h2>
¤ ¦ ¸ ¼ ½ ¾
<h2>bnlnot; Non-Letters N4 (normative) </h2>
-omitted-
<h2>dc; Combining diacritics (normative)</h2>
-omitted-
<h2>gl; Greek Letters (extended)</h2>
Ά Έ Ή Ί Ό Ύ Ώ ΐ Α Β Γ Δ Ε Ζ Η Θ Ι Κ Λ Μ Ν Ξ Ο Π Ρ Σ
Τ Υ Φ Χ Ψ Ω Ϊ Ϋ ά έ ή ί ΰ α β γ δ ε ζ η θ ι κ λ μ ν
ξ ο π ρ ς σ τ υ φ χ ψ ω ϊ ϋ ό ύ ώ
<h2>cl; Cyrillic Letters (extended)</h2>
Ѝ А Б В Г Д Е Ж З И Й К Л М Н О П Р С Т У Ф Х Ц Ч Ш
Щ Ъ Ь Ю Я а б в г д е ж з и й к л м н о п р с т у ф
х ц ч ш щ ъ ь ю я ѝ
<h2>enl; Non-Letters E1 (extended)</h2>
ƒ ʰ ʳ ˆ ˜ ˢ ᵈ ᵗ ‘ ‚ “ ” „ † … ‰ ′ ″ ‹ › ⁰ ⁴ ⁵ ⁶ ⁷ ⁸
⁹ ⁿ ₀ ₁ ₂ ₃ ₄ ₅ ₆ ₇ ₈ ₉ ™ ∞ ≤ ≥
</body>
</html>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
Copyright 2026 The Arimo Project Authors (https://github.com/googlefonts/Arimo)

This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
https://openfontlicense.org


-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).

"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.

"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are
not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
Loading