How Do I Serve PDF Files in a Lift Application

71 views
Skip to first unread message

Neil Visnapuu

unread,
Apr 30, 2012, 1:08:43 PM4/30/12
to lif...@googlegroups.com

Hi - I'm looking for some guidance as to how one might incorporate PDF files in a lift stack.  I know you can just link to a PDF, but what I'd like to do is serve / not serve the PDF based on similar logic as to how I serve HTML pages.  For example, if I want a subset of users to have access to a view, I can define that subset via query in Boot, define a function that determines if the current users is in that group, and attach that function to the Loc / Menu.

Can I do the same thing for a PDF, or XLS, or Word document?

David Pollak

unread,
Apr 30, 2012, 4:57:42 PM4/30/12
to lif...@googlegroups.com
Please see Lift's RestHelper and Scala's pattern matching and guards:

object MyPdfServer extends RestHelper {
  serve {
    case "api" :: "pdf" Get _ if canServePdf => LiftResponse(...)
  }
}

The logic in canServePdf computes if it's legal to serve the PDF file.  For more info, please see http://simply.liftweb.net/index-5.3.html#toc-Section-5.3

On Mon, Apr 30, 2012 at 10:08 AM, Neil Visnapuu <neil.v...@gmail.com> wrote:

Hi - I'm looking for some guidance as to how one might incorporate PDF files in a lift stack.  I know you can just link to a PDF, but what I'd like to do is serve / not serve the PDF based on similar logic as to how I serve HTML pages.  For example, if I want a subset of users to have access to a view, I can define that subset via query in Boot, define a function that determines if the current users is in that group, and attach that function to the Loc / Menu.

Can I do the same thing for a PDF, or XLS, or Word document?

--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code



--
Visi.Pro, Cloud Computing for the Rest of Us http://visi.pro
Lift, the simply functional web framework http://liftweb.net


Neil Visnapuu

unread,
Apr 30, 2012, 5:27:22 PM4/30/12
to lif...@googlegroups.com
Thanks! I am literally getting Lift into some of the largest
investment houses, via a compliance framework, and it's going great,
but for their absolute insistence on having all data that resides in a
nice, meaningful database, splattered on timestamped PDFs!

David Pollak

unread,
Apr 30, 2012, 6:10:32 PM4/30/12
to lif...@googlegroups.com
On Mon, Apr 30, 2012 at 2:27 PM, Neil Visnapuu <neil.v...@gmail.com> wrote:
Thanks!  I am literally getting Lift into some of the largest
investment houses, via a compliance framework, and it's going great,
but for their absolute insistence on having all data that resides in a
nice, meaningful database, splattered on timestamped PDFs!

I look forward to your success!

Lukasz Kuczera

unread,
May 1, 2012, 2:14:45 PM5/1/12
to lif...@googlegroups.com
Well everyone knows that PDF is best database solution in the world ... at least in financial sector.
Reply all
Reply to author
Forward
0 new messages