Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updates to use PDType0Font in the doc #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ this directory like the following (you'll have to replace the question marks):
-->
<groupId>com.planbase.pdf</groupId>
<artifactId>PdfLayoutManager</artifactId>
<version>1.0.1</version>
<version>1.0.2</version>
<packaging>jar</packaging>

<name>PdfLayoutManager</name>
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/com/planbase/pdf/layoutmanager/PdfLayoutMgr.java
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,13 @@ private PdfLayoutMgr(PDColorSpace cs, PDRectangle mb) {
: mb;
}

private PdfLayoutMgr(PDColorSpace cs, PDRectangle mb, PDDocument document) {
doc = document;
colorSpace = cs;
pageSize = (mb == null) ? PDRectangle.LETTER
: mb;
}

/**
Returns a new PdfLayoutMgr with the given color space.
@param cs the color-space.
Expand Down Expand Up @@ -396,6 +403,11 @@ public static PdfLayoutMgr newRgbPageMgr() {
return new PdfLayoutMgr(PDDeviceRGB.INSTANCE, null);
}

@SuppressWarnings("UnusedDeclaration") // Part of end-user public interface
public static PdfLayoutMgr newRgbPageMgr(PDDocument document) {
return new PdfLayoutMgr(PDDeviceRGB.INSTANCE, null, document);
}

/** Returns the page width given the defined PDRectangle pageSize */
public double pageWidth() { return pageSize.getWidth(); }

Expand Down
12 changes: 6 additions & 6 deletions src/main/java/com/planbase/pdf/layoutmanager/TextStyle.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
import java.awt.Color;
import java.io.IOException;

import org.apache.pdfbox.pdmodel.font.PDFont;
import org.apache.pdfbox.pdmodel.font.PDFontDescriptor;
import org.apache.pdfbox.pdmodel.font.PDType1Font;

/**
Specifies font, font-size, color, and padding. Immutable.
*/
public class TextStyle {

private final PDType1Font font;
private final PDFont font;
private final Color textColor;
private final double fontSize;

Expand All @@ -36,7 +36,7 @@ public class TextStyle {
private final double descent;
private final double leading;

private TextStyle(PDType1Font f, double sz, Color tc, double leadingFactor) {
private TextStyle(PDFont f, double sz, Color tc, double leadingFactor) {
if (f == null) { throw new IllegalArgumentException("Font must not be null"); }
if (tc == null) { tc = Color.BLACK; }

Expand Down Expand Up @@ -67,7 +67,7 @@ private TextStyle(PDType1Font f, double sz, Color tc, double leadingFactor) {
}

/** Creates a TextStyle with the given font, size, color, and a leadingFactor of 0.5. */
public static TextStyle of(PDType1Font f, double sz, Color tc) {
public static TextStyle of(PDFont f, double sz, Color tc) {
return new TextStyle(f, sz, tc, 0.5);
}

Expand All @@ -78,7 +78,7 @@ font descent (how far letters like g, q, j, etc. go below the baseline of letter
A leadingFactor of 1 will result of a leading equal to the descent, while a leadingFactor
of 2 will result of a leading equal to twice the descent etc...
*/
public static TextStyle of(PDType1Font f, double sz, Color tc, double leadingFactor) {
public static TextStyle of(PDFont f, double sz, Color tc, double leadingFactor) {
return new TextStyle(f, sz, tc, leadingFactor);
}

Expand All @@ -97,7 +97,7 @@ public double stringWidthInDocUnits(String text) {
}
}

public PDType1Font font() { return font; }
public PDFont font() { return font; }
public double fontSize() { return fontSize; }

public Color textColor() { return textColor; }
Expand Down