Re: Embedding PDF from file system in webpage

Tony Corless via Exist-open <[email protected]> Wed, 15 May 2024 07:52:02 +0000
Newsgroups gmane.text.xml.exist
Message-ID <DB9PR06MB8043DF9B3C4A0E36B2B35D75D1EC2@DB9PR06MB8043.eurprd06.prod.outlook.com>
Dear Jean-Paul,

Thanks, having read it twice that makes perfect sense. The file is available locally to a browser but (currently) is not accessible over the network, so I now understand what I have to fix.

Kind regards,
Tony



From: Jean-Paul Rehr <[email protected]>
Sent: Tuesday, May 14, 2024 10:22 PM
To: Corless, Tony (Comp Sci & Elec Eng) <[email protected]>
Cc: [email protected]
Subject: Re: [Exist-open] Embedding PDF from file system in webpage

Dear Tony,

The fact that your file on your file server is accessible to eXist is not really material, and is a distraction from the root cause of the problem.

Is your  variable $document a URL where the PDF can be accessed via the web?  If so, that link should work in a browser...so if you copy and paste it, the file shoud be available? If it is not, then the link is not correct, or your file server is not configured (with a proxy server) to serve files to the internet...

eXist is only transmitting a link to the browser via the attribute src;  it's the browser that acts upon the link that is in the attribute.

Cheers,
JPR



On Tue, May 14, 2024 at 10:18 PM Tony Corless via Exist-open <[email protected]<mailto:[email protected]>> wrote:
Apologies for bothering people, as the answer to this perhaps should be obvious to me.

For a while I have been using a query, as below, to display PDF documents with some header information that is stored as XML data in eXist.
To date, the PDFs have been small and stored in the eXist database or accessed from a remote server.

Now I have some much larger PDF documents that ideally I will keep in the local file system rather than in the database.
To achieve that I need to change the source in the <embed> below to access the document from the file system.

While I assumed that would be trivial my attempts to date have failed. Any pointer to the correct approach is welcome, as clearly I have misunderstood something.

(The file:exists function has confirmed that I have correct and accessible files in the file system, I can read these but have failed to render them as PDF.)


xquery version "3.1";
declare option exist:serialize "method=html media-type=text/html";
(: declare variable $documentName := request:get-parameter("documentName",()); :)

let $documentName :="1021-COP"

let $xmlCollection := collection("/db/apps/controlledDocuments/data/current")
let $document :=$xmlCollection[./document/documentName=$documentName]/document/documentLink

return
    <html>
        <body>
            <h1>Some info about {$documentName}</h1>
            <embed src='{$document}' style="width:100%;height:90%;"></embed>
        </body>
    </html>


Many thanks for any assistance.

Tony Corless


_______________________________________________
Exist-open mailing list
[email protected]<mailto:[email protected]>
https://lists.sourceforge.net/lists/listinfo/exist-open

_______________________________________________
Exist-open mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/exist-open