May 13, 2011 at 6:53 am
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
May 13, 2011 at 6:59 am
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?
May 13, 2011 at 10:10 am
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 Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
May 24, 2011 at 9:03 am
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
May 24, 2011 at 9:22 am
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 Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
May 24, 2011 at 9:25 am
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 Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
May 24, 2011 at 9:29 am
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.
May 24, 2011 at 9:48 am
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.
-- Gianluca Sartori
June 1, 2011 at 2:22 am
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
June 30, 2022 at 11:21 am
This reply has been reported for inappropriate content.
Text to PDF Editor: this is your ultimate space for making things worth it. MJ PDF Editor allows you to edit your pdf documents with ease.
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply