Skip anchors when generating PDF
This commit is contained in:
@@ -176,6 +176,7 @@ class NWBuildDocument:
|
|||||||
|
|
||||||
elif bFormat == nwBuildFmt.PDF:
|
elif bFormat == nwBuildFmt.PDF:
|
||||||
makeObj = ToQTextDocument(self._project)
|
makeObj = ToQTextDocument(self._project)
|
||||||
|
makeObj.disableAnchors()
|
||||||
filtered = self._setupBuild(makeObj)
|
filtered = self._setupBuild(makeObj)
|
||||||
makeObj.initDocument()
|
makeObj.initDocument()
|
||||||
yield from self._iterBuild(makeObj, filtered)
|
yield from self._iterBuild(makeObj, filtered)
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ class ToQTextDocument(Tokenizer):
|
|||||||
self._bold = QFont.Weight.Bold
|
self._bold = QFont.Weight.Bold
|
||||||
self._normal = QFont.Weight.Normal
|
self._normal = QFont.Weight.Normal
|
||||||
self._newPage = False
|
self._newPage = False
|
||||||
|
self._anchors = True
|
||||||
|
|
||||||
self._pageSize = QPageSize(QPageSize.PageSizeId.A4)
|
self._pageSize = QPageSize(QPageSize.PageSizeId.A4)
|
||||||
self._pageMargins = QMarginsF(20.0, 20.0, 20.0, 20.0)
|
self._pageMargins = QMarginsF(20.0, 20.0, 20.0, 20.0)
|
||||||
@@ -107,6 +108,11 @@ class ToQTextDocument(Tokenizer):
|
|||||||
self._newPage = state
|
self._newPage = state
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def disableAnchors(self) -> None:
|
||||||
|
"""Disable anchors for when writing to file."""
|
||||||
|
self._anchors = False
|
||||||
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
# Class Methods
|
# Class Methods
|
||||||
##
|
##
|
||||||
@@ -341,18 +347,22 @@ class ToQTextDocument(Tokenizer):
|
|||||||
cFmt.setForeground(self._theme.text)
|
cFmt.setForeground(self._theme.text)
|
||||||
primary = None
|
primary = None
|
||||||
elif fmt == TextFmt.ANM_B:
|
elif fmt == TextFmt.ANM_B:
|
||||||
cFmt.setAnchor(True)
|
if self._anchors:
|
||||||
cFmt.setAnchorNames([data])
|
cFmt.setAnchor(True)
|
||||||
|
cFmt.setAnchorNames([data])
|
||||||
elif fmt == TextFmt.ANM_E:
|
elif fmt == TextFmt.ANM_E:
|
||||||
cFmt.setAnchor(False)
|
if self._anchors:
|
||||||
|
cFmt.setAnchor(False)
|
||||||
elif fmt == TextFmt.ARF_B:
|
elif fmt == TextFmt.ARF_B:
|
||||||
cFmt.setFontUnderline(True)
|
if self._anchors:
|
||||||
cFmt.setAnchor(True)
|
cFmt.setFontUnderline(True)
|
||||||
cFmt.setAnchorHref(data)
|
cFmt.setAnchor(True)
|
||||||
|
cFmt.setAnchorHref(data)
|
||||||
elif fmt == TextFmt.ARF_E:
|
elif fmt == TextFmt.ARF_E:
|
||||||
cFmt.setFontUnderline(False)
|
if self._anchors:
|
||||||
cFmt.setAnchor(False)
|
cFmt.setFontUnderline(False)
|
||||||
cFmt.setAnchorHref("")
|
cFmt.setAnchor(False)
|
||||||
|
cFmt.setAnchorHref("")
|
||||||
elif fmt == TextFmt.HRF_B:
|
elif fmt == TextFmt.HRF_B:
|
||||||
cFmt.setForeground(self._theme.link)
|
cFmt.setForeground(self._theme.link)
|
||||||
cFmt.setFontUnderline(True)
|
cFmt.setFontUnderline(True)
|
||||||
@@ -426,7 +436,7 @@ class ToQTextDocument(Tokenizer):
|
|||||||
cFmt.setForeground(self._theme.head if hCol else self._theme.text)
|
cFmt.setForeground(self._theme.head if hCol else self._theme.text)
|
||||||
cFmt.setFontWeight(self._bold if self._boldHeads else self._normal)
|
cFmt.setFontWeight(self._bold if self._boldHeads else self._normal)
|
||||||
cFmt.setFontPointSize(self._sHead.get(hType, 1.0))
|
cFmt.setFontPointSize(self._sHead.get(hType, 1.0))
|
||||||
if hKey:
|
if hKey and self._anchors:
|
||||||
cFmt.setAnchorNames([hKey])
|
cFmt.setAnchorNames([hKey])
|
||||||
cFmt.setAnchor(True)
|
cFmt.setAnchor(True)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user