PDF image link only

Does anybody know a simple solution to show only the pdf icon as a link to a stored pdf (document filename) and hide the filename or is there a setting for that?

1 Like

OK - no suggestion. My problem is that my pdf file names are very long. That widens the grid over the screen borders. Is there a possibility to cut the pdf names or to limit the column width?

HI Joe,

If you only want an icon that will link to a document then it will do the following:

add a field named “image” ( On the screen as Document link new )

Create an OnRecord event and add the code:

// $ at_path = “…/…/file/doc/”; // server link to * .pdf - !!! Not tested !!!

$ at_path = “…/…/…/file/doc/”; // local link to * .pdf
$ doc_name = {link}; // {link} = field name
$ d_link = ($ at_path. “/”. $ doc_name);

{image} = “<a href=”.$d_link."> <img src = ‘… / _ lib / img / grp__NM__img__NM__PDF-icon.jpg’ /> </a>";

I attach a picture.

Attention! Link is not ideal. Opens the document directly in the browser.
It will still be necessary to correct the code.

Maybe somebody else will help us.

[ATTACH=CONFIG]n83626[/ATTACH]

pdf_grid.jpg

1 Like

Hi rik, thanks for your suggestion. I’ll give it a try :wink:

Hi rik this works but shows obviously the pdf name and the direct link on the server. I wonder if there is another way with a macro to generate the link to the file?

Yes I know.
OK, the next solution is identical to the normal click on the linked document name.

It opens a popup window asking if you want to open the document or save it to disk.
Did you mean this solution?

In this case, replace the line:

{image} = “<a href=”.$d_link."> <img src = ‘… / _ lib / img / grp__NM__img__NM__PDF-icon.jpg’ /> </a>";

with new:

{image} = “<a href=”.$d_link." download target =’_blank’><img src=’…/_lib/img/grp__NM__img__NM__PDF-icon.jpg’/></a>";

Hi rik, thank you that works. It would be nice if the direct URL to the document would not be visible. That’s why I’m asking if there is a solution to generate the link with a macro.

No problem.
Go to the Field position option
and move the field to the left. (the field you want to hide)

Look at the picture. In my case, this field is “link”
[ATTACH=CONFIG]n83677[/ATTACH]

pdf_grid2.jpg

But if you want to have a link button instead of an icon then use this line:

{image} = ‘<a href=’.$d_link.’ download target ="_blank" class=“scButton_small” title=“Press to download document!”>DOWNLOAD DOCUMENT </a>’;

Hi rik, the button is a nice feature :wink: But the link of the document is still visible in the browser status line if you move your mouse over the button. I’d like to hide the link…
But I’m thinking about another solution that the user can’t guess other file names. Maybe it’s possible to save the pdf and give it a random file name…

Hi Joe,
Have you already solved your problem?
I was a little on vacation, so I answer a little late.

I found another solution to hide the link to a document, but I do not like it personally.

You’re missing a popup window asking if you want to open a document or download.
The document opens directly in a new window.

If this solution helps you, the code below is how you do it. The code is for the button.

$at_path = “…/…/…/file/doc/”; // local link to *.pdf
$doc_name = {link};
$d_link=($at_path."/".$doc_name);

?>
<script>

$(document).ready(function () {
setTimeout(function () {

$(‘a[href]#no-link’).each(function () {
var href = this.href;

$(this).removeAttr(‘href’).css(‘cursor’, ‘pointer’).click(function () {
if (href.toLowerCase().indexOf("#") >= 0) {

} else {
window.open(href, ‘_blank’);
}
});
});

}, 500);
});

</script>

<?php

{image_link} = ‘<a href=’.$d_link.’ id=“no-link” download target ="_blank" class=“scButton_small” title=“Press to download document!”>DOWNLOAD DOCUMENT </a>’;

1 Like

Hi rik, thanks for the suggestion. I will try this but first I have to work with that because I do not understand the javascript code :wink: