Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XFRX - Hyperlinks to local files - Anyone done this?

Status
Not open for further replies.

GriffMG

Programmer
Mar 4, 2002
6,309
FR
I have been asked to supply a copy of the attachment data from one of my systems.
All the attachments remain in the file system, organised by originator.

In this instance there are probably something like half a million files - amounting to 60GB of data.

I would like to supply some of the meta data relating to the files in a VFP report, so that would have the
originators name, the title, the number and the revision of each document, and a list of the files related to it.

So far that all exists... I would like the report presented as a PDF on a drive along with the actual files and for the
recipient to be able to open the PDF, search for the title or whatever, click on the file name and have the file open (mostly they are PDFs too).

I use XFRX to create the PDF and I've been able to open a hyperlink to a web page, but not a local file... it might be a security restriction?

Is this doable?

I could write a VFP app to do it, or perhaps do it in an excel file... but the pdf approach seems very open and pretty universal?

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Well, not so well.

I have it installed and its works for my existing reports - apart from screwing up the print of images from general fields for some reason.

The relative links are not working yet, I can see they are trying, but I think they are coded to expect either a fully qualified URL or a full
path - not a relative one.

I have emailed their support.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
They are coded to expect a fully qualified URL.

For now I'm out a few bucks with no solution today.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Hi Mike

By fully qualified I mean either of these

file:///
or

file:///g:/myfolder/mypdf.pdf

I can't do the latter because I can't know the drive letter in advance, and the former is no good, because the data is local.

Have to use excel, or wait....

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
But, surely, however you create the link, you are going to need the drive letter? I don't think a [tt]file:///[/tt] link can take a relative path (or can it?).

Later: Or maybe it can. I just tried it in Word. I inserted a link to a local file without a drive letter, and the file opened OK. But that probably won't help you.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Hi

Yes, the pdf format allows for a relative link with no drive specified, looking at the pdf with a hex editor reveals it uses a different notation to that used for a URI hyperlink though.

So, the nice authors at XFRX have said they may be able to do it, but I'm out of time for this exercise - I have to get the hard drive in the post shortly.

Despite this niggle, I remain so impressed with XFRX and their people, even if I am somewhat out of pocket, the breadth of support for VFP is amazing.

Back to version 12.4 for me for now though

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Update, the XFRX people just sent me a new version to try - and it works!

Just the logo to sort (or remove for now)… Sorry, update to the update, they are helping me with that too.

EqeusCom support rocks!

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Now you should tell how you create relative links.

I just tried my own idea with Word documents linking to others and that actually works relative, ie when you rename the folder the other document is still found relative to the first, as DOCX.
If you save as PDF Word does not convert the hyperlink to refer to the other PDF, it's still a link to the DOCX. While PDFs created with a docx->PDF converter let a link point to the other PDF, not DOCX.

Security actually comes into play but from the PDF reader. You can allow links to other documents to work, it's not a problem of creating this, or technically. I have not looked under the hood how the links are rleative in the pdf, because when the trust manager pops up a warning the links are displayed as absolute file links, but the folder name changes, so I assume internally it's "file://./" for "this folder" and then "./ is turned to current folder before this goes to navigate and then trigger safe read mode, as it's called here.

Aside of that problem you can obviously configure, if a user wants a PDF "site" working that way.

Now the confusing part, when I look into the PDF files raw with notepad++ you see a mix of cleartext and binary "streams", as PDF is a mixed format, the word saved PDFs contain a link as
Code:
obj
<</Subtype/Link/Rect[ 130.18 677.31 186.98 702.75] /BS<</W 0>>[highlight #FCE94F]/F 4/A<</Type/Action/S/URI/URI(Document2.docx)[/highlight] >>>>
endobj
And the converted PDF has:
Code:
obj
<<
[highlight #FCE94F]/F (Document2.docx) 
/S /Launch 
[/highlight]>>
endobj
The important parts highlighted. Bith link types ar to DOCX, the same PDF reader takes the first definition to go to the other DOCX, while the other links is reinterpreted to mean the PDF, even though the links both point to DOCX.

So overall I see it's having multiple solutions, it works on the basis of PDF specific linking, which does not take file URLs but some PDF specific commands.

But the next funny thing about it is, when the warnings are shown in the PDF reader, that you're about to launch another reader for the other PDF or DOCX, the links are displayed as (absolute) file links, I guess the way the link is executed is by converting this PDF internal URI definition into something the OS can resolve and so such links may be executed by Shellexecute of a file link.

Last not least, when you look into the DOCX (copy as zip, unzip, look into the xml files) you also don't simply find a file link, in _rels subfolder document.xml.rels defines
Code:
<Relationship [highlight #FCE94F]Id="rId4"[/highlight] Type="[URL unfurl="true"]http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"[/URL] [highlight #FCE94F]Target="Document2.docx" TargetMode="External"[/highlight]/></Relationships>
And in document.xml it's referred to as
Code:
<[highlight #FCE94F]w:hyperlink r:id="rId4"[/highlight] w:history="1"><w:r w:rsidRPr="00DE3F5F"><w:rPr><w:rStyle w:val="Hyperlink"/></w:rPr><w:t>Document2</w:t></w:r></w:hyperlink>

So neither docx nor pdf are internally working with a normal URI schema.

I would look into the final PDFs you now generate, but it seems they did a custom feature to convert your way of embedding links into something PDF gets. It's really not straight forward and I guess you can forget to achieve this without XFRX by a PDF printer, because you'd first need to establish a VFP internal concept of links in reports.

In HTML a href="./Document2.html" works, so not even making it a file link, just a relative link.

Anyway, congratulations to what you achieved from and with Eqeus.

Bye, Olaf.

Olaf Doschke Software Engineering
 
Hi Olaf

It's done by opening the report form in the designer, getting the properties up for a text field in the details band.
Select the Other tab, and click on the Edit Comment button.

In there I have put

Code:
#UR A HREF="file:\\"+DOS_FILE(tmpiv.MADEBY)+"\"+ALLTRIM(TMPIV.ATTFILE)

The DOS_FILE() function just changes anything not allowed as a folder name to an underscore as the tmpiv.madeby field could have commas, quotes or colons and slashes.

In my new version of XFRX (19.1 and a bit) this creates a relative link to the file from the PDF.

The resultant link comes up as
Works very well (note the reversal of the slashes).

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Well, I'd like to see what's raw in the PDF, my PDF viewer also shows me links as file:// links, though clearly they are not embedded in the document.
Also backslashes are wrong in file links to start with, Windows is just graceful with both. No URI schema is defined by MS, they all always work with slashes and not backslashes. On a windows computer a file link might have backslashes, too, but the protocol decribing part of such URLs also is [highlight #FCE94F]file://[/highlight], not file[highlight #FCE94F]:\\[/highlight]. Acceptance of backslashes also in thet start part of a URL wouldn#t even be necessary to tolerate, see generic scheme.

Anyway, thanks for posting how this works in XFRX. That should help others to get the same feature going and that's what counts most.

Bye, Olaf.

Olaf Doschke Software Engineering
 
Just one more thing I'd test, if I were you: If you rename the root folder with all your final PDFs, do the links still work?
Assume you generate all these PDFs, zip it up and someone else unzips into any another location, will this all still reference each other relatively? My guess is you need a [highlight #FCE94F]./[/highlight] either before or instead of the folder name.

Bye, Olaf.

Olaf Doschke Software Engineering
 
No problem, it looks like this:

Code:
obj
<<
/Type /Annot
/Subtype /Link
/F 4
/Rect [78.3700 689.8688 386.6200 700.3688]
/Border [0 0 0]
/A <</S /URI 
/URI (ARCH_2__\\080-FNF-BLOCK E - ISSUE REGISTER_T1_MASTIC - EXTERNAL.PDF)
 >>
>>
endobj

The relativity seems to work from wherever the report PDF is saved, so long as the desired files are in the same structure below it.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Thanks Griff,

I see that it's not including drive and any part of the fullpath up to "ARCH_2__", but if you'd not store the PDFs in a folder "ARCH_2__" it seems this would stop working. Also makes me wonder how a PDF viewr displaying a document from an ARCH_2__ folder wouldn't interpret this relative to the location meaning another subfolder of the same name.

From my examples, the URI reference didn't contain a folder name, as the referred PDF is in the same folder, simply just the other file name.

Bye, Olaf.

Olaf Doschke Software Engineering
 
Hi Olaf

There are too many files not to have them organised a little bit, and yes the folders do have to match or things will be lost.

The folders are made by the system and the report is from the system so, as long as no one moves the report pdf from the folder above the subfolders all should be well.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Well, to do without specific folder names in the URIs doesn't mean to do without the folders, it just could be /URI ([highlight #FCE94F]./[/highlight]080-FNF-BLOCK E - ISSUE REGISTER_T1_MASTIC - EXTERNAL.PDF)
Only files referring to other files in another folder, say PDFs in folder ARCH_3__ would need to use /URI ([highlight #FCE94F]../ARCH_2__/[/highlight]080-FNF-BLOCK E - ISSUE REGISTER_T1_MASTIC - EXTERNAL.PDF) to refer to a PDF not in the same but in a parallel folder.

Then, of course, it all still depends on these folder names to stay intact, but it doesn't need any specific root.

Even if this only is in a concrete file share in your company, you would want to create PDFs, that will survive a move of the whole archive to some other base folder, say the folder that boith contains ARCH_2__ and the ARCH_3__ I made up.

Every relative link - just think of normal relative file paths - lives on the knowledge of the file hierarhy its stored in, the ..\ parts of a relative file name don't ask of you to know how your parent fodlers are named, you simply go up N folders by prepending N times ..\, but when you then want to decend into other subfolders than you came from, you refer to them with their name, so files in FolderA referring to files in a parallel FolderB need to goo ..\FolderB and files in FolderB which refer to files in FolderA need to go ..\FolderA to get there. The whole set of files therefore still make this a rigid subfolder structure, there's nothing that solves that problem, but if folderA and folderB are in a root folder never explicitly part of the descending part of any relative path, then this could change, including a server move from \\server1\shareX\pdfs\ to \\server14\shareY\pdfs\ and that's what I'd like to gurantee.

If you generate all these PDFs on the fly every time over and over again, it'll just be a case of changing your base path, but if these PDFs should be able to have a long life cycle, they better not depend on a root portion of the fullpath to be only where it is right now.

Just like a good VFP project also is movable and a PJX only references files within a home path. Things like files from VFP HOME() better are referred to as HOME()+x, which then becomes a concept relative paths can't do, but that's just specific to VFP. A set of files referring to other files of the whole file set should not need to refer to each other by absolute paths to remain movable. Folders become part of the moving structure, that's not problematic, but this structure as a whole has to be movable.

and while we're at VFP project files. Look into the classloc data of VCXes, direclty as DBF, not what the property window shows. When a parent class is in a VCX in the same folder, classloc will only contain that other vcx name. the files are referred to relatively, not relative to a project home, but relative to themselve and that's what each PDF also has to do. A reader opening any first PDF of your set has no concept of a base folder of the whole set, paths within that PDF are relative to it, not relative to a root folder.

Bye, Olaf.

Olaf Doschke Software Engineering
 
It's a one off exercise Olaf, putting a mass of files on a USB hard drive, along with a pdf to help the end recipient locate specific documents.

It's not meant to be a live system at all, no modifications and no additions or deletions, just half a million documents handed over when my client sells his project on completion(ish).

After that it's not my responsibility any longer - but I would like it to be usable to some degree by the recipient if he/she is interested.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Then it's even most important the links work by being relative to each PDF itself.

Perhaps this way: For the PDF viewer the "here" or home location is the pdf it displays. documents in the same folder would be addressed by their name (other.pdf) only, pdfs in a subfolder by .\subfolder\other.pdf. documents in a parent folder ..\other.pdf and so on.

The way you generate links they all seem to be based in a pattern starting in some root folder, I don't see how that will work in general, only in special cases and you might just have been lucky your case is one of them. The PDF viewer has no concept of a curdir or base directory. Instead, it will always orient relative links to the PDF displayed currently.

Or do you only have one table of content PDF and all the others are anywhere else from there and don't contain links to other documents, only your one overview index PDF?

Bye, Olaf.

Olaf Doschke Software Engineering
 
The last sentence is correct, one table of contents or index if you like, each entry going to a single document - opening it in a new window, leaving the index open for more searching.
There might be a hundred sub folders under the index, with 5,000 files in each - most of which will be pdf, but 25% would probably be dwg, and some docx, xlsx and others such as rvt. It's the complete history of the design for two large blocks of flats in London - detailing everything from landscaping to finishes on kitchen cupboards and tiles in bathrooms.

Further update: the people at Eqeus have also resolved my problem with the bitmap logo from a general field.

Really can't praise them enough.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top