Only add page break before first line of a heading in PDF and preview (#2415)
This commit is contained in:
@@ -40,8 +40,9 @@ from novelwriter.formats.shared import BlockFmt, BlockTyp, T_Formats, TextFmt, s
|
||||
from novelwriter.formats.tokenizer import HEADINGS, Tokenizer
|
||||
from novelwriter.types import (
|
||||
QtAlignAbsolute, QtAlignCenter, QtAlignJustify, QtAlignLeft, QtAlignRight,
|
||||
QtKeepAnchor, QtMoveAnchor, QtPageBreakAfter, QtPageBreakBefore,
|
||||
QtPropLineHeight, QtTransparent, QtVAlignNormal, QtVAlignSub, QtVAlignSuper
|
||||
QtKeepAnchor, QtMoveAnchor, QtPageBreakAfter, QtPageBreakAuto,
|
||||
QtPageBreakBefore, QtPropLineHeight, QtTransparent, QtVAlignNormal,
|
||||
QtVAlignSub, QtVAlignSuper
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@@ -253,8 +254,10 @@ class ToQTextDocument(Tokenizer):
|
||||
|
||||
elif tType in HEADINGS:
|
||||
bFmt, cFmt = self._genHeadStyle(tType, tMeta, bFmt)
|
||||
newBlock(cursor, bFmt)
|
||||
cursor.insertText(tText, cFmt)
|
||||
for tPart in tText.split("\n"):
|
||||
newBlock(cursor, bFmt)
|
||||
cursor.insertText(tPart, cFmt)
|
||||
bFmt.setPageBreakPolicy(QtPageBreakAuto)
|
||||
|
||||
elif tType == BlockTyp.SEP:
|
||||
newBlock(cursor, bFmt)
|
||||
|
||||
@@ -52,6 +52,7 @@ QtVAlignSuper = QTextCharFormat.VerticalAlignment.AlignSuperScript
|
||||
|
||||
QtPageBreakBefore = QTextFormat.PageBreakFlag.PageBreak_AlwaysBefore
|
||||
QtPageBreakAfter = QTextFormat.PageBreakFlag.PageBreak_AlwaysAfter
|
||||
QtPageBreakAuto = QTextFormat.PageBreakFlag.PageBreak_Auto
|
||||
|
||||
QtPropLineHeight = 1 # QTextBlockFormat.LineHeightTypes.ProportionalHeight
|
||||
|
||||
|
||||
Reference in New Issue
Block a user