- adding custom ttf font
- print transparent text
- set raw transformation matrix
This commit is contained in:
Jindra Petřík
2021-02-18 22:12:42 +01:00
parent fd48d65e1d
commit edb4686ebe
11 changed files with 1103 additions and 209 deletions

View File

@@ -22,6 +22,7 @@ package gnu.jpdf;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.print.PageFormat;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.Serializable;
@@ -217,6 +218,30 @@ public class PDFPage extends PDFObject implements Serializable
return f;
}
public PDFFont getEmbeddedFont(String font, int style, File file) throws IOException {
// Search the fonts on this page, and return one that matches this
// font.
// This keeps the number of font definitions down to one per font/style
for (PDFFont ft : fonts) {
if (ft.equals("/TrueType", font, style)) {
return ft;
}
}
// Ok, the font isn't in the page, so create one.
// We need a procset if we are using fonts, so create it (if not
// already created, and add to our resources
if (fonts.size() == 0) {
addProcset();
procset.add("/Text");
}
// finally create and return the font
PDFFont f = pdfDocument.getEmbeddedFont(font, style, file);
fonts.addElement(f);
return f;
}
/**
* Returns the page's PageFormat.
* @return PageFormat describing the page size in device units (72dpi)