SQLServerCentral.com / SQL Server 2008 / SQL Server Newbies / Retrieve PDF data from database into a file. / Latest PostsInstantForum.NET v99.99.99SQLServerCentral.comhttp://www.sqlservercentral.com/Forums/notifications@sqlservercentral.comFri, 09 Dec 2016 07:26:41 GMT20RE: Retrieve PDF data from database into a file.http://www.sqlservercentral.com/Forums/Topic1108390-1292-1.aspxThanks everyone,It's now clear that my approach is wrong. I had a look at Steve's link and that will help mewith the other applications/languages we use over here.I'm familiar with several languages but just not with SQL Server.kind regards,Walter GrimmWed, 01 Jun 2011 02:22:45 GMTwgrimmRE: Retrieve PDF data from database into a file.http://www.sqlservercentral.com/Forums/Topic1108390-1292-1.aspxEvery time I had to do something similar to this, I used Crystal Reports.You can create a report with an Image field and read it from a binary column in your db. Once you have the report object ready, you can export it to PDF and stream it to the client.You can do it with a web app or with a web service (I'm using the latter to achieve maximum flexibility).I think you could also do it via CLR, but I don't see the need for such a feature in the database.Tue, 24 May 2011 09:48:06 GMTspaghettidbaRE: Retrieve PDF data from database into a file.http://www.sqlservercentral.com/Forums/Topic1108390-1292-1.aspxThis might help: [url]http://geekswithblogs.net/pakistan/archive/2005/04/19/36884.aspx[/url]You need to SELECT the data from the table, but the client has to deal with the stream.Tue, 24 May 2011 09:29:15 GMTSteve Jones - SSC EditorRE: Retrieve PDF data from database into a file.http://www.sqlservercentral.com/Forums/Topic1108390-1292-1.aspxAlso there is no need to have store these as a file on the server for the chance that somebody wants to view it. It is really quick and easy to assemble on demand. For your windows app you will probably have to save the byte stream to a file on disc. For you web app you can stream it directly to the response (and set the response mime type), no need to save it to disc at all.Tue, 24 May 2011 09:25:05 GMTSean LangeRE: Retrieve PDF data from database into a file.http://www.sqlservercentral.com/Forums/Topic1108390-1292-1.aspxSo do you have pdf or images stored? either way it is basically the same thing. You can pull it out of the db into a byte array. From there you can stream it to where ever it needs to go. What language(s) are you trying to do this in? Web based, windows based?Tue, 24 May 2011 09:22:00 GMTSean LangeRE: Retrieve PDF data from database into a file.http://www.sqlservercentral.com/Forums/Topic1108390-1292-1.aspxThanks for your replies.We have several applications that need to retrieve the PDF from the database. In some cases the PDF must be mailed or presented on a website or downloaded as a file. Not all the applications are web-based and one of the options is to have some of the PDF files ready on the server in which case I'd have to create the files from the SQL data.For this I want to know how to recreate the PDF file from the database data. I'm hoping it's straightforward.kind regards,Walter GrimmTue, 24 May 2011 09:03:32 GMTwgrimmRE: Retrieve PDF data from database into a file.http://www.sqlservercentral.com/Forums/Topic1108390-1292-1.aspxPresumably you want to send this to the front end? What language? This is usually pretty simple.Fri, 13 May 2011 10:10:30 GMTSean LangeRE: Retrieve PDF data from database into a file.http://www.sqlservercentral.com/Forums/Topic1108390-1292-1.aspxI'm not 100% sure of the context.I've done this a few times in a web application to show the pdf to the web users (no differences there... materialized pdf can be shown or sent).I don't understand if and why you want to do this on the server.So what's the full story about this business requirement?Fri, 13 May 2011 06:59:47 GMTNinja's_RGR'usRetrieve PDF data from database into a file.http://www.sqlservercentral.com/Forums/Topic1108390-1292-1.aspxHi,I have read many of the posts about retrieving image data from a table but I must be missing something.I have a table with invoices stored as PDF image data. I now have to retrieve the binary invoice data and write it to a PDF file so it can be read with Adobe Reader or send via email.How do I go about achieving this using TSQL ? Or do I have to use CLR (of which I'm not sure yet what that is).The sample.jpg shows an example of the stored data.Thanks,WalterFri, 13 May 2011 06:53:46 GMTwgrimm