Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2008
»
SQL Server Newbies
»
Retrieve PDF data from database into a file.
Retrieve PDF data from database into a file.
Rate Topic
Display Mode
Topic Options
Author
Message
wgrimm
wgrimm
Posted Friday, May 13, 2011 6:53 AM
Forum Newbie
Group: General Forum Members
Last Login: Wednesday, June 01, 2011 2:18 AM
Points: 8,
Visits: 37
Hi,
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,
Walter
Post Attachments
sample.jpg
(
22 views,
25.08 KB
)
Post #1108390
Ninja's_RGR'us
Ninja's_RGR'us
Posted Friday, May 13, 2011 6:59 AM
SSC-Insane
Group: General Forum Members
Last Login: Yesterday @ 7:02 PM
Points: 21,376,
Visits: 9,584
I'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?
Post #1108391
Sean Lange
Sean Lange
Posted Friday, May 13, 2011 10:10 AM
SSCrazy Eights
Group: General Forum Members
Last Login: Today @ 3:32 PM
Points: 8,980,
Visits: 8,540
Presumably you want to send this to the front end? What language? This is usually pretty simple.
_______________________________________________________________
Need help? Help us help you.
Read the article at
http://www.sqlservercentral.com/articles/Best+Practices/61537/
for best practices on asking questions.
Need to split a string? Try Jeff Moden's
splitter
.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Post #1108603
wgrimm
wgrimm
Posted Tuesday, May 24, 2011 9:03 AM
Forum Newbie
Group: General Forum Members
Last Login: Wednesday, June 01, 2011 2:18 AM
Points: 8,
Visits: 37
Thanks 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 Grimm
Post #1114113
Sean Lange
Sean Lange
Posted Tuesday, May 24, 2011 9:22 AM
SSCrazy Eights
Group: General Forum Members
Last Login: Today @ 3:32 PM
Points: 8,980,
Visits: 8,540
So 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?
_______________________________________________________________
Need help? Help us help you.
Read the article at
http://www.sqlservercentral.com/articles/Best+Practices/61537/
for best practices on asking questions.
Need to split a string? Try Jeff Moden's
splitter
.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Post #1114137
Sean Lange
Sean Lange
Posted Tuesday, May 24, 2011 9:25 AM
SSCrazy Eights
Group: General Forum Members
Last Login: Today @ 3:32 PM
Points: 8,980,
Visits: 8,540
Also 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.
_______________________________________________________________
Need help? Help us help you.
Read the article at
http://www.sqlservercentral.com/articles/Best+Practices/61537/
for best practices on asking questions.
Need to split a string? Try Jeff Moden's
splitter
.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Post #1114140
Steve Jones - SSC Editor
Steve Jones - SSC Editor
Posted Tuesday, May 24, 2011 9:29 AM
SSC-Dedicated
Group: Administrators
Last Login: Today @ 5:09 AM
Points: 31,526,
Visits: 13,864
This might help:
http://geekswithblogs.net/pakistan/archive/2005/04/19/36884.aspx
You need to SELECT the data from the table, but the client has to deal with the stream.
Follow me on Twitter:
@way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
Post #1114144
spaghettidba
spaghettidba
Posted Tuesday, May 24, 2011 9:48 AM
SSCarpal Tunnel
Group: General Forum Members
Last Login: Yesterday @ 3:43 AM
Points: 4,804,
Visits: 8,091
Every 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.
Get your two-cent-answer quickly
The Spaghetti DBA
Post #1114170
wgrimm
wgrimm
Posted Wednesday, June 01, 2011 2:22 AM
Forum Newbie
Group: General Forum Members
Last Login: Wednesday, June 01, 2011 2:18 AM
Points: 8,
Visits: 37
Thanks everyone,
It's now clear that my approach is wrong. I had a look at Steve's link and that will help me
with the other applications/languages we use over here.
I'm familiar with several languages but just not with SQL Server.
kind regards,
Walter Grimm
Post #1117915
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.