Re: [MarkLogic Dev General] Serving PDFs from the MarkLogic Server
Here is an example of an xqy file that does what David is talking about, using fn:doc to serve up a pdf stored as
binary in MarkLogic:
(: pdf.xqy :)
xquery version"1.0-ml";
xdmp:set-response-content-type("application/pdf"),
let $pdf := xdmp:get-request-field("pdf","")
return
fn:doc($pdf)
And then you can call this from some html in another XQY file, something like this:
(: some other xqy :)
<a href="pdf.xqy?pdf=/my/pdf/uri/doc.pdf" target="_blank">View my PDF file in a new window</a>
-Danny
From: general-bounces@...
[mailto:general-bounces <at> developer.marklogic.com] On Behalf Of David Lee
Sent: Wednesday, July 11, 2012 2:08 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Serving PDFs from the MarkLogic Server
You can server PDF's if you store them as a binary file.
You can also dynamically generate them (but it requires an app server).
I have done both and served them from a ML application no problem.
You do want to set the mime-type correctly for the response.
-----------------------------------------------------------------------------
David Lee
Lead Engineer
MarkLogic Corporation
dlee@...
Phone: +1 650-287-2531
Cell: +1 812-630-7622
www.marklogic.com
This e-mail and any accompanying attachments are confidential. The information is intended solely for
the use of the individual to whom it is addressed. Any review, disclosure, copying, distribution, or use
of this e-mail communication by others is strictly prohibited. If you are not the intended recipient,
please notify us immediately by returning this message to the sender and delete all copies. Thank you for
your cooperation.
From: general-bounces@...
[mailto:general-bounces <at> developer.marklogic.com] On Behalf Of DJaun Maclin
Sent: Wednesday, July 11, 2012 5:06 PM
To: General Discussion
Subject: [MarkLogic Dev General] Serving PDFs from the MarkLogic Server
Hi everyone,
I was wondering how could I serve PDF files in the Marklogic Server to the outside world for downloading and
viewing purposes. I would love to have a direct link to the PDF file store in the database. Has anyone dealt
with this before?
Thanks
Dj