Skip to content

Bugfix/issue 1274 - HTML export - When image and text divs are rendered one … #1275

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

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
5 changes: 5 additions & 0 deletions openpdf/src/main/java/com/lowagie/text/html/HtmlWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,7 @@ protected void write(Element element, int indent) throws IOException {
case Element.PHRASE: {
Phrase phrase = (Phrase) element;
styleAttributes = new Properties();
styleAttributes.setProperty(Markup.CSS_KEY_DISPLAY, Markup.CSS_VALUE_GRID);
if (phrase.hasLeading()) {
styleAttributes.setProperty(Markup.CSS_KEY_LINEHEIGHT, phrase.getLeading() + "pt");
}
Expand All @@ -691,6 +692,7 @@ protected void write(Element element, int indent) throws IOException {
case Element.ANCHOR: {
Anchor anchor = (Anchor) element;
styleAttributes = new Properties();
styleAttributes.setProperty(Markup.CSS_KEY_DISPLAY, Markup.CSS_VALUE_GRID);
if (anchor.hasLeading()) {
styleAttributes.setProperty(Markup.CSS_KEY_LINEHEIGHT, anchor.getLeading() + "pt");
}
Expand Down Expand Up @@ -721,9 +723,11 @@ protected void write(Element element, int indent) throws IOException {
case Element.PARAGRAPH: {
Paragraph paragraph = (Paragraph) element;
styleAttributes = new Properties();
styleAttributes.setProperty(Markup.CSS_KEY_DISPLAY, Markup.CSS_VALUE_GRID);
if (paragraph.hasLeading()) {
styleAttributes.setProperty(Markup.CSS_KEY_LINEHEIGHT, paragraph.getTotalLeading() + "pt");
}

// start tag
addTabs(indent);
writeStart(HtmlTags.DIV);
Expand Down Expand Up @@ -990,6 +994,7 @@ protected void writeSection(Section section, int indent) throws IOException {
depth = 5;
}
Properties styleAttributes = new Properties();
styleAttributes.setProperty(Markup.CSS_KEY_DISPLAY, Markup.CSS_VALUE_GRID);
if (section.getTitle().hasLeading()) {
styleAttributes.setProperty(Markup.CSS_KEY_LINEHEIGHT, section.getTitle().getTotalLeading() + "pt");
}
Expand Down
5 changes: 5 additions & 0 deletions openpdf/src/main/java/com/lowagie/text/html/Markup.java
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,11 @@ public class Markup {
*/
public static final String CSS_VALUE_BLOCK = "block";

/**
* A possible value for the DISPLAY key
*/
public static final String CSS_VALUE_GRID = "grid";

/**
* a CSS value for text font weight
*/
Expand Down