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