Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using FSO to view a PDF through the BinaryWrite

Status
Not open for further replies.

Dynapen

Programmer
Apr 20, 2000
245
US
Here's the problem. I am using the FSO in ASP to pull up some PDF files that we have stored on the server, and then outputting them to the client. I need to use the FSO so that I can do security checks on the user before displaying the images, which i can't do by linking direclty to the PDF file (which I can't password protect)

I have the ASP page built to pull the file, and display it but I am getting a error. Some PDF files work, and some don't. All are named in the same convention, so that's not the problem. I have looked at the properties of all the PDF's and they all seem to be the same, but some just won't work. Instead of opening Adobe and allowing you to view the file, it just comes up blank.

No error is displayed by IE(5.0-6.0) but the status bar displays the following when it finishes trying to load one of the PDF's that comes up blank.

"An error has occurred while trying to use this document."

Any ideas?
 
So why would certain PDF files work, and other files not.....All are scanned in same version of PDF?
 
A solution I thought of (may not be the best) is to store the pdf file in a database as a blob then you can check weather the user is allowed to view the file.

The download link is an actual asp page and not the pdf file eg. /files/pdf/myfile.pdf that way even if a user gets the link to the asp page they won't be able to download it without supplying crudentials to the page.
 
So is there anyway to fix the binary configuration.....so that it will successfully transmit back and forth to the ASCII.....?
 
No. The only "fix" is to read binary data as binary however the FSO can not do that. You need a VB component.
See
Excerpt:
"Many developers appreciate the ease of using the Scripting.FileSystemObject to open an ASCII file and then display its contents in Microsoft Word or Microsoft Excel from within Internet Explorer. In its current inception, ASP does not directly provide any comparable objects to read files that contain binary data such as an Excel worksheet with macros, an Adobe Acrobat (.pdf) file, a .gif image, or any other files that contain binary data. However, an ASP developer can write a custom business object or component that adds this functionality." Compare Code (Text)
Generate Sort in VB or VBScript
 
I know this thread is old but... You could use the ADODB.stream class. It is a stream that can handle binary. It also has the advantage of having a stm.loadfromfile which can be used to read the file into memory and then:
Code:
stm.type = adTypeBinary
stm.loadfile strFile
response.write stm.read
________________________________________
Nature and Nature's laws lay hid in night
God said "Let Newton be", and all was light
~Alexander Pope~
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top