### HTML Attribute Examples Source: https://github.com/zxfr/pd4ml-examples/blob/master/src/main/java/html/H001.htm Shows various ways to define attributes within HTML start tags, including unquoted, quoted, and empty attribute values. ```html ``` -------------------------------- ### Clone PD4ML Examples Repository Source: https://github.com/zxfr/pd4ml-examples/blob/master/README.md Command to retrieve the PD4ML examples project from the GitHub repository. ```bash git clone https://github.com/zxfr/pd4ml-examples.git ``` -------------------------------- ### Apply CSS styling to HTML documents Source: https://github.com/zxfr/pd4ml-examples/blob/master/src/main/java/html/H001.htm Provides an example of using the style element to define global CSS rules for an HTML document, specifically changing background and text colors. ```html
This page is just a demo.
``` -------------------------------- ### Identify invalid HTML semantic combinations Source: https://github.com/zxfr/pd4ml-examples/blob/master/src/main/java/html/H001.htm Examples of semantically contradictory HTML elements where roles or types conflict, leading to conformance errors. ```htmlThis is a simple sample.
``` -------------------------------- ### Custom HTML Tag Rendering with Java Graphics2D (Java) Source: https://context7.com/zxfr/pd4ml-examples/llms.txt Enables rendering custom HTML tags by extending PD4ML's CustomTag class and registering a handler. This example demonstrates drawing a star shape. Requires PD4ML library and Java AWT. ```java import java.awt.Color; import java.awt.Graphics2D; import java.awt.geom.GeneralPath; import java.io.ByteArrayInputStream; import java.io.FileOutputStream; import com.pd4ml.Constants; import com.pd4ml.CustomTag; import com.pd4ml.PD4ML; import com.pd4ml.fonts.FontCache; public class CustomTagExample { public static class StarTag extends CustomTag { public StarTag() {} public StarTag(String code, FontCache fontCache, CustomTag prime) { super(code, fontCache, prime); } @Override public CustomTag getInstance(String code, FontCache fontCache) { return new StarTag(code, fontCache, this); } @Override public void paint(float x, float y, float width, float height, float containerWidth, float containerHeight, Graphics2D g) { g.setColor(Color.red); float min = Math.min(width, height); float base = min * 0.5f; y += min * 0.07f; GeneralPath path = new GeneralPath(); path.moveTo(x + base * 0.1f, y + base * 0.65f); path.lineTo(x + base * 1.9f, y + base * 0.65f); path.lineTo(x + base * 0.40, y + base * 1.65f); path.lineTo(x + base, y); path.lineTo(x + base * 1.60f, y + base * 1.65f); path.closePath(); g.fill(path); } @Override public boolean isEmptyTag() { return true; } } public static void main(String[] args) throws Exception { PD4ML pd4ml = new PD4ML(); // Register custom tag handler pd4ml.addCustomTagHandler("star", new StarTag()); // Use custom tag in HTML String html = "TEST STAR [This is very wrong!
This is correct.
``` -------------------------------- ### Configure Custom TTF Fonts in PD4ML with Java Source: https://context7.com/zxfr/pd4ml-examples/llms.txt Supports TrueType fonts (TTF) via directory-based loading or pre-indexed font mapping files for improved performance. This Java example shows two methods: direct font directory usage and using a pre-generated index file for faster font resolution. ```java import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileOutputStream; import com.pd4ml.PD4ML; import com.pd4ml.fonts.FontCache; public class FontConfigurationExample { public static void main(String[] args) throws Exception { // Option 1: Direct font directory usage (slower, indexes on the fly) PD4ML pd4ml1 = new PD4ML(); pd4ml1.useTTF("c:/windows/fonts", true); // true = force re-index // Option 2: Pre-indexed font file (faster for repeated use) // First, generate the index file once: File index = File.createTempFile("pd4fonts", ".properties"); FontCache.generateFontPropertiesFile("c:/windows/fonts", index.getAbsolutePath(), (short)0); // Then use the index file: PD4ML pd4ml2 = new PD4ML(); pd4ml2.useTTF(index.getAbsolutePath()); // Command line alternative: // java -jar pd4ml.jar -configure.fonts