diff --git a/src/Services/EDA/KiCadHelper.php b/src/Services/EDA/KiCadHelper.php
index 882152dd..c526c1c7 100644
--- a/src/Services/EDA/KiCadHelper.php
+++ b/src/Services/EDA/KiCadHelper.php
@@ -44,6 +44,9 @@ class KiCadHelper
/** @var int The maximum level of the shown categories. 0 Means only the top level categories are shown. -1 means only a single one containing */
private readonly int $category_depth;
+ /** @var bool Whether to resolve actual datasheet PDF URLs (true) or use Part-DB page links (false) */
+ private readonly bool $datasheetAsPdf;
+
public function __construct(
private readonly NodesListBuilder $nodesListBuilder,
private readonly TagAwareCacheInterface $kicadCache,
@@ -55,6 +58,7 @@ class KiCadHelper
KiCadEDASettings $kiCadEDASettings,
) {
$this->category_depth = $kiCadEDASettings->categoryDepth;
+ $this->datasheetAsPdf = $kiCadEDASettings->datasheetAsPdf;
}
/**
@@ -216,9 +220,13 @@ class KiCadHelper
UrlGeneratorInterface::ABSOLUTE_URL
);
- //Try to find an actual datasheet attachment (by type name, attachment name, or PDF extension)
- $datasheetUrl = $this->findDatasheetUrl($part);
- $result["fields"]["datasheet"] = $this->createField($datasheetUrl ?? $partUrl);
+ //Try to find an actual datasheet attachment (configurable: PDF URL vs Part-DB page link)
+ if ($this->datasheetAsPdf) {
+ $datasheetUrl = $this->findDatasheetUrl($part);
+ $result["fields"]["datasheet"] = $this->createField($datasheetUrl ?? $partUrl);
+ } else {
+ $result["fields"]["datasheet"] = $this->createField($partUrl);
+ }
$result["fields"]["Part-DB URL"] = $this->createField($partUrl);
//Add basic fields
diff --git a/src/Settings/MiscSettings/KiCadEDASettings.php b/src/Settings/MiscSettings/KiCadEDASettings.php
index d8f1026d..29b579a2 100644
--- a/src/Settings/MiscSettings/KiCadEDASettings.php
+++ b/src/Settings/MiscSettings/KiCadEDASettings.php
@@ -43,4 +43,9 @@ class KiCadEDASettings
envVar: "int:EDA_KICAD_CATEGORY_DEPTH", envVarMode: EnvVarMode::OVERWRITE)]
#[Assert\Range(min: -1)]
public int $categoryDepth = 0;
+
+ #[SettingsParameter(label: new TM("settings.misc.kicad_eda.datasheet_link"),
+ description: new TM("settings.misc.kicad_eda.datasheet_link.help"),
+ envVar: "bool:EDA_KICAD_DATASHEET_AS_PDF", envVarMode: EnvVarMode::OVERWRITE)]
+ public bool $datasheetAsPdf = true;
}
\ No newline at end of file
diff --git a/translations/messages.en.xlf b/translations/messages.en.xlf
index 9c811a21..a15d27f1 100644
--- a/translations/messages.en.xlf
+++ b/translations/messages.en.xlf
@@ -9993,6 +9993,18 @@ Please note, that you can not impersonate a disabled user. If you try you will g
This value determines the depth of the category tree, that is visible inside KiCad. 0 means that only the top level categories are visible. Set to a value > 0 to show more levels. Set to -1, to show all parts of Part-DB inside a sigle cnategory in KiCad.
+
+
+ settings.misc.kicad_eda.datasheet_link
+ Datasheet field links to PDF
+
+
+
+
+ settings.misc.kicad_eda.datasheet_link.help
+ When enabled, the datasheet field in KiCad will link to the actual PDF file (if found). When disabled, it will link to the Part-DB page instead. The Part-DB page link is always available as a separate "Part-DB URL" field.
+
+ settings.behavior.sidebar