Manuel,

This is exactly how we present confidential reports to our clients. The PDF
is stored in a VARCHAR column, and dynamically delivered to the client
without writing a file to the server drive. The technique prohibits
bookmarking of a location, and insures that the user is properly
authenticated.

Use a Search action to select the varchar into a local Tango variable (named
LOCAL$lvPDF in the example below), then use the following code in a results
action (this is Tango 2000 only):


<@ASSIGN LOCAL$fileName VALUE="YourFilenameHere.pdf">

<@PURGERESULTS><@EXCLUDE>
<@ASSIGN LOCAL$encodeResults VALUE=FALSE>
<@ASSIGN local$httpHeader VALUE="Content-Type:
application/pdf<@CRLF><@CRLF>">
</@EXCLUDE><@VAR LOCAL$lvPDF ENCODING=NONE>

There are some very important gotchas:

There can be no push attributes in the taf file before the local$httpHeader
variable is set. Sending any data before the httpHeader variable is set will
cause Tango to issue the default header, resulting in the client receiving
your document as plain HTML. In other words, once the http header has been
sent from Tango, it cannot be changed.

There can be no data at all, including white space, before or after the
expression of the varchar variable. Any stray characters will be appended to
the data stream sent to the client, resulting in corruption the PDF file
structure. That is why the @purgeresults and @exclude tags are so important.
Do not put any carriage returns after the /@exclude tag. This includes all
of the taf file that executes, before or after this results action.

Finally, you have to trick MSIE into believing that it is actually reading a
file. It seems to give preference to the path of the file over the http
header. Fortunately this is easy: It turns out that IIS, Apache, and maybe
all http servers read a URL left to right. So you can create a seemingly
bogus url such as:

http://www.coffeylabs.com/taf/reports/privatereports.taf/YourFilenameHere.pd
f?argument1=value1&argument2=etc

Notice that I put a "/YourFilenameHere.pdf after the .taf! The server will
ignore the junk after /privatereports.taf until it reads the ?, and then it
will capture the arguments as usual. The client browser will not. Instead,
the browser will read /YourFilenameHere.pdf as the end of the path, and
correctly initiate a file download.

Note that this technique works equally well for other file types such as
Excel. We have some very happy clients because they have access to Excel
formatted data in real time.

Good Luck,
Paul


> I been working on a dynamic PDF generation system can can utilize RBase
> report designer.  I got the system working and now I can deploy dynamic
> RBase/PDF reports.  The problem I encountered is that if the new PDF
> report has a name of a report previously viewed  by the user, the
> browser shows the old report unless a browser refresh is issued.  Of
> course, we can change the browser's setting to refresh every time and
> not use the cache but this would slow down the system.
> The solution that I am exploring is generating the PDF report and
> loading it into a VARCHAR column that Tango can Query and display
> directly.  This would be similar as displaying a VARBIT picture image
> stored in a column.
>
> Is there a way to display a VARCHAR column that contains a PDF file as a
> PDF document?
>
> Thanks In Advance for your help,
> Manuel
>

Reply via email to