Hi. All.
I have openacs3.x running on my dev box and am trying to figure out
how to use HTMLDOC to output pdf file.
I create a filter similar to file-storage and a proc similiar to fs-
file-downloader, which creates a link for user to download a pdf file
created by htmldoc in the /tmp directory.
The code of the proc is "
proc_doc pdf_downloader {conn key } "" {
set_the_usual_form_variables
if { [empty_string_p $file_name] } {
return filter_break
}
set file_name_html "$file_name.html"
set file_name_pdf "$file_name.pdf"
if {[catch {exec htmldoc --webpage -f $file_name_pdf
$file_name_html} errmsg]} {
ad_return_error Error $errmsg
}
ns_returnfile 200 "application/pdf" $file_name_pdf
return filter_return
}
This proc is invoked by this link "/document/doc.pdf?
file_name=/tmp/docXXXXXX", which is created by another proc.
$file_name_html is already created in /tmp directory.
I put "
ns_section "ns/mimetypes"
ns_param ".pdf" "application/pdf"
" in nsd.tcl file.
It works well till the last step, which gives me the following error:
"Error
PAGES: 1 BYTES: 3612
".
If I reload the page, it gives me some additional info:
"
Error
PAGES: 1 BYTES: 3612
mailto:webmaster@localhost.localdomain
HTTP/1.0 200 OK MIME-Version: 1.0 Date: Fri, 03 May 2002 01:25:01 GMT
Server: AOLserver/3.4.2 Content-Type:
text/html Content-Length: 245 Connection: close Last-Modified: Fri,
03 May 2002 01:25:01 GMT Content-Type:
application/pdf Content-Length: 3612 %PDF-1.3 %âãÃ
".
Don't know exactly what the problem is. The pdf file is created in
the /tmp directory but is not returned to the browser.
I tried file-storage module to upload a pdf file and I can download
it from the link created by fs-file-downloader. But that page uses
db_blob to return the file.
Is this a problem with mime type? Ns_returnfile doesn't return that
pdf file correctly.
I tried "ns_write "output-type : application/pdf" $file_name_pdf"
and "ns_respond -status 200 -type "application/pdf" -file
$file_name_pdf" and both don't work.
Any feedback is appreciated!