-
Notifications
You must be signed in to change notification settings - Fork 4.8k
[css] margin not working in html plugin #413 #414
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
Merged
+9
−4
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
* 2014 Diego Casorran, https://github.com/diegocr | ||
* 2014 Daniel Husar, https://github.com/danielhusar | ||
* 2014 Wolfgang Gassler, https://github.com/woolfg | ||
* 2014 Steven Spungin, https://github.com/flamenco | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining | ||
* a copy of this software and associated documentation files (the | ||
|
@@ -811,13 +812,13 @@ | |
out, | ||
paragraphspacing_after, | ||
paragraphspacing_before, | ||
priorblockstype, | ||
priorblockstyle, | ||
styles, | ||
fontSize; | ||
fragments = PurgeWhiteSpace(this.paragraph.text); | ||
styles = this.paragraph.style; | ||
blockstyle = this.paragraph.blockstyle; | ||
priorblockstype = this.paragraph.blockstyle || {}; | ||
priorblockstyle = this.paragraph.priorblockstyle || {}; | ||
this.paragraph = { | ||
text : [], | ||
style : [], | ||
|
@@ -832,8 +833,11 @@ | |
maxLineHeight = void 0; | ||
defaultFontSize = 12; | ||
fontToUnitRatio = defaultFontSize / this.pdf.internal.scaleFactor; | ||
paragraphspacing_before = (Math.max((blockstyle["margin-top"] || 0) - (priorblockstype["margin-bottom"] || 0), 0) + (blockstyle["padding-top"] || 0)) * fontToUnitRatio; | ||
this.priorMarginBottom = this.priorMarginBottom || 0; | ||
paragraphspacing_before = (Math.max((blockstyle["margin-top"] || 0) - this.priorMarginBottom, 0) + (blockstyle["padding-top"] || 0)) * fontToUnitRatio; | ||
paragraphspacing_after = ((blockstyle["margin-bottom"] || 0) + (blockstyle["padding-bottom"] || 0)) * fontToUnitRatio; | ||
this.priorMarginBottom = blockstyle["margin-bottom"] || 0; | ||
|
||
out = this.pdf.internal.write; | ||
i = void 0; | ||
l = void 0; | ||
|
@@ -863,8 +867,9 @@ | |
indentMove = wantedIndent - currentIndent; | ||
currentIndent = wantedIndent; | ||
} | ||
var indentMore = (Math.max(blockstyle["margin-left"] || 0, 0)) * fontToUnitRatio; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a hack. It seems that margin-left is considered in the line margin logic, but not scaled. (Putting a giant value in will have an effect on the original code.) |
||
//move the cursor | ||
out(indentMove, (-1 * defaultFontSize * maxLineHeight).toFixed(2), "Td"); | ||
out(indentMove + indentMore, (-1 * defaultFontSize * maxLineHeight).toFixed(2), "Td"); | ||
i = 0; | ||
l = line.length; | ||
while (i !== l) { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should have been priorblockstype AKA priorblockstyle. Yes?
Even with this change, code is not working. This method is sometimes called with phantom empty paragraphs that reset the state. Workaround is to use this.priorMarginBottom instead. That may not be best solution however.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Er, dunno.. i'm not familiar enough with that code, so i'll just assume you're correct, it indeed seems so :)