Skip to content

Commit d13953f

Browse files
committed
Add DisableAutoLinks advanced setting to disable PDF auto-linking
When enabled, SumatraPDF no longer turns plain-text URLs and email addresses in PDFs into clickable links. Native PDF hyperlinks are unaffected. (fixes #5703)
1 parent 6465d65 commit d13953f

7 files changed

Lines changed: 30 additions & 7 deletions

File tree

cmd/gen-settings.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,14 @@ const globalPrefs: Field[] = [
801801
mkField("DisableAntiAlias", Bool, false, "if true, disables anti-aliasing for rendering PDF documents"),
802802
"3.6",
803803
),
804+
setExpert(
805+
mkField(
806+
"DisableAutoLinks",
807+
Bool,
808+
false,
809+
"if true, disables auto-linking of URLs and email addresses found in PDF text",
810+
),
811+
),
804812
setExpert(
805813
mkField(
806814
"UseSysColors",

docs/md/Advanced-options-settings.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ UIFontSize = 0
182182
; version 3.6)
183183
DisableAntiAlias = false
184184
185+
; if true, disables auto-linking of URLs and email addresses found in PDF text
186+
DisableAutoLinks = false
187+
185188
; if true, we use Windows system colors for background/text color. Over-rides
186189
; other settings
187190
UseSysColors = false

docs/md/Version-history.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
Available in [pre-release](https://www.sumatrapdfreader.org/prerelease) builds.
66

7+
- add `DisableAutoLinks` advanced setting to disable auto-linking of URLs and email addresses found in PDF text (fixes #5703)
78
- the `FixedPageUI.SelectionColor` advanced setting now honors an alpha channel: set an `#aarrggbb` value (e.g. `#40f5fc0c`) to make the text-selection overlay more transparent so selected text stays crisp instead of looking washed out; `#rrggbb` keeps the previous default opacity (fixes #3209)
89
- middle-click auto-scroll is now smooth: it's driven by a high-frequency timer with fractional-pixel accumulation instead of a coarse 20ms timer with integer steps, so it no longer looks choppy (also enables fine, slow scroll speeds) (fixes #2693)
910
- add `CmdStartAutoScroll` (`Start Auto-Scroll` in the `Ctrl + k` command palette) to start middle-click-style auto-scroll without a middle mouse button (useful on laptops / trackpads): it anchors at the cursor, then move the cursor away to scroll; invoke again or middle-click to stop. Bind it to a key via [shortcuts](Customizing-keyboard-shortcuts.md)

src/EngineBase.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ class EngineBase {
426426
bool hasPageLabels = false;
427427
bool hideAnnotations = false;
428428
bool disableAntiAlias = false;
429+
bool disableAutoLinks = false;
429430
int pageCount = -1;
430431

431432
StrVec errors;

src/EngineCreate.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ EngineBase* CreateEngineFromFile(const char* path, PasswordUI* pwdUI, bool enabl
262262
if (engine) {
263263
engine->SetFilePath(path);
264264
engine->disableAntiAlias = gGlobalPrefs->disableAntiAlias;
265+
engine->disableAutoLinks = gGlobalPrefs->disableAutoLinks;
265266
return engine;
266267
}
267268
} else {
@@ -286,6 +287,7 @@ EngineBase* CreateEngineFromFile(const char* path, PasswordUI* pwdUI, bool enabl
286287
EngineBase* engine = CreateEngineForKind(kind, contentHint, path, pwdUI, enableChmEngine);
287288
if (engine) {
288289
engine->disableAntiAlias = gGlobalPrefs->disableAntiAlias;
290+
engine->disableAutoLinks = gGlobalPrefs->disableAutoLinks;
289291
return engine;
290292
}
291293

@@ -300,6 +302,7 @@ EngineBase* CreateEngineFromFile(const char* path, PasswordUI* pwdUI, bool enabl
300302
}
301303
if (engine) {
302304
engine->disableAntiAlias = gGlobalPrefs->disableAntiAlias;
305+
engine->disableAutoLinks = gGlobalPrefs->disableAutoLinks;
303306
}
304307
return engine;
305308
}

src/EngineMupdf.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2053,6 +2053,7 @@ EngineBase* EngineMupdf::Clone() {
20532053
delete pwdUI;
20542054

20552055
clone->disableAntiAlias = disableAntiAlias;
2056+
clone->disableAutoLinks = disableAutoLinks;
20562057

20572058
if (!decryptionKey.s && pdfdoc && pdfdoc->crypt) {
20582059
clone->decryptionKey = Str();
@@ -3303,7 +3304,9 @@ FzPageInfo* EngineMupdf::GetFzPageInfo(int pageNo, bool loadQuick, fz_cookie* co
33033304
return pageInfo;
33043305
}
33053306

3306-
FzLinkifyPageText(pageInfo, stext);
3307+
if (!disableAutoLinks) {
3308+
FzLinkifyPageText(pageInfo, stext);
3309+
}
33073310
FzFindImagePositions(ctx, pageNo, pageInfo->images, stext);
33083311
fz_drop_stext_page(ctx, stext);
33093312
return pageInfo;

src/Settings.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,9 @@ struct GlobalPrefs {
519519
int uIFontSize;
520520
// if true, disables anti-aliasing for rendering PDF documents
521521
bool disableAntiAlias;
522+
// if true, disables auto-linking of URLs and email addresses found in
523+
// PDF text
524+
bool disableAutoLinks;
522525
// if true, we use Windows system colors for background/text color.
523526
// Over-rides other settings
524527
bool useSysColors;
@@ -924,6 +927,7 @@ static const FieldInfo gGlobalPrefsFields[] = {
924927
{offsetof(GlobalPrefs, treeFontSize), SettingType::Int, 0},
925928
{offsetof(GlobalPrefs, uIFontSize), SettingType::Int, 0},
926929
{offsetof(GlobalPrefs, disableAntiAlias), SettingType::Bool, false},
930+
{offsetof(GlobalPrefs, disableAutoLinks), SettingType::Bool, false},
927931
{offsetof(GlobalPrefs, useSysColors), SettingType::Bool, false},
928932
{offsetof(GlobalPrefs, useTabs), SettingType::Bool, true},
929933
{offsetof(GlobalPrefs, tabsMru), SettingType::Bool, false},
@@ -974,17 +978,17 @@ static const FieldInfo gGlobalPrefsFields[] = {
974978
{(size_t)-1, SettingType::Comment, (intptr_t)"Settings below are not recognized by the current version"},
975979
};
976980
static const StructInfo gGlobalPrefsInfo = {
977-
sizeof(GlobalPrefs), 91, gGlobalPrefsFields,
981+
sizeof(GlobalPrefs), 92, gGlobalPrefsFields,
978982
"\0\0CheckForUpdates\0CustomScreenDPI\0DefaultDisplayMode\0DefaultZoom\0EnableTeXEnhancements\0EscToExit\0FullPathI"
979983
"nTitle\0InverseSearchCmdLine\0LazyLoading\0MainWindowBackground\0NoHomeTab\0HomePageSortByFrequentlyRead\0ReloadMo"
980984
"difiedDocuments\0RememberOpenedFiles\0RememberStatePerDocument\0RestoreSession\0ReuseInstance\0ShowMenubar\0ShowMe"
981985
"nubarWithTabs\0ShowTips\0CustomColors\0ShowToolbar\0ShowFavorites\0ShowToc\0ShowLinks\0ShowStartPage\0SidebarDx\0S"
982986
"crollbars\0ScrollbarInSinglePage\0SmoothScroll\0CitationHoverDelay\0FastScrollOverScrollbar\0PreventSleepInFullscr"
983-
"een\0TabWidth\0Theme\0TocDy\0ToolbarSize\0TreeFontName\0TreeFontSize\0UIFontSize\0DisableAntiAlias\0UseSysColors\0"
984-
"UseTabs\0TabsMru\0ZoomLevels\0ZoomIncrement\0\0FixedPageUI\0\0EBookUI\0\0ComicBookUI\0\0ImageUI\0\0ChmUI\0\0Annota"
985-
"tions\0\0ExternalViewers\0\0ForwardSearch\0\0PrinterDefaults\0\0Fullscreen\0\0SelectionHandlers\0\0Shortcuts\0\0Th"
986-
"emes\0\0TabGroups\0\0\0DefaultPasswords\0UiLanguage\0VersionToSkip\0WindowState\0WindowPos\0FileStates\0SessionDat"
987-
"a\0ReopenOnce\0TimeOfLastUpdateCheck\0OpenCountWeek\0PropWinPos\0\0"};
987+
"een\0TabWidth\0Theme\0TocDy\0ToolbarSize\0TreeFontName\0TreeFontSize\0UIFontSize\0DisableAntiAlias\0DisableAutoLin"
988+
"ks\0UseSysColors\0UseTabs\0TabsMru\0ZoomLevels\0ZoomIncrement\0\0FixedPageUI\0\0EBookUI\0\0ComicBookUI\0\0ImageUI"
989+
"\0\0ChmUI\0\0Annotations\0\0ExternalViewers\0\0ForwardSearch\0\0PrinterDefaults\0\0Fullscreen\0\0SelectionHandlers"
990+
"\0\0Shortcuts\0\0Themes\0\0TabGroups\0\0\0DefaultPasswords\0UiLanguage\0VersionToSkip\0WindowState\0WindowPos\0Fil"
991+
"eStates\0SessionData\0ReopenOnce\0TimeOfLastUpdateCheck\0OpenCountWeek\0PropWinPos\0\0"};
988992
static const FieldInfo gTheme_1_Fields[] = {
989993
{offsetof(Theme, name), SettingType::String, (intptr_t)""},
990994
{offsetof(Theme, textColor), SettingType::Color, (intptr_t)""},

0 commit comments

Comments
 (0)