Forum Discussion
dKayt
May 07, 2025Copper Contributor
Open PDF documents in a new tab
Hi all, is it possible to open a PDF Document in a new tab using JSON formatting? Best Regarding, dKayt
- May 11, 2025
Hi dKayt, try this code ->
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "a", "attributes": { "href": "=[$FileRef]", "target": "_blank" }, "children": [ { "elmType": "span", "txtContent": "[$FileLeafRef]" } ] }
dKayt
May 13, 2025Copper Contributor
This is the final code. I've put it here as a backup for myself and for anyone else who might need it ^^
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/view-formatting.schema.json",
"hideSelection": true,
"hideColumnHeader": true,
"rowFormatter": {
"elmType": "a",
"attributes": {
"href": "[$FileRef]",
"target": "_blank"
},
"style": {
"display": "flex",
"align-items": "center",
"text-decoration": "none",
"border": "1px solid #e0e0e0",
"border-radius": "5px",
"margin": "8px"
},
"children": [
{
"elmType": "img",
"attributes": {
"src": "@thumbnail.medium"
},
"style": {
"width": "100px",
"height": "100px",
"max-height": "120px"
}
},
{
"elmType": "span",
"txtContent": "[$FileLeafRef]",
"style": {
"font-size": "13px",
"font-weight": "600",
"margin": "20px",
"color": "#000"
}
}
]
}
}