Link to home
Start Free TrialLog in
Avatar of jrogovsky
jrogovsky

asked on

CR.Net: dynamic image loading from url stored in sql database, output as pdf

Hi,

I'm having a heck of a time trying to get any of the potential work arounds for CR not liking to load images dynamically to work.

Does anyone have a working solution for CR.Net?

I have a SQL database with thousands of user profiles. Each profile record contains a url to a JPG image of the user. I'd like to make a CR.Net report that shows 4 images per page and outputs to PDF. I already have a report that creates a rectangle placeholder for each image and we've been using it to manually print the pages and glue pictures onto the paper. But it's now time for a more complete solution.

I can easily get just what I want without Crystal if I use ASP.Net capability to render dynamic html in real-time. But then I lose control of page breaks and margins. I've looked into .Net plug-ins for generating PDFs from html in real time and I think that's what I'll fall back on if I can't get Crystal to work.

Anyway, I hope I've properly described what I'm trying to accomplish. Please let me know if you need further elaboration.
Avatar of ebolek
ebolek

I have answered this question before

Check this out. It has the code and explain how to d oit

https://www.experts-exchange.com/questions/21094752/Load-a-picture-in-runtime.html
Regards
Emre
Avatar of jrogovsky

ASKER

Thanks. I'll review the other thread. I'll probably have some questions. I'll accept the solution here once I've had a chance to review it. I hope the rules allow you to get my points for this even though it's a question that's already been asked; as far as I'm concerned this solution is worth 10,000 points!
The common technique that I've heard people using is to simply create a dynamic dataset and base your report off the ado.net dataset (general walkthru: http://support.businessobjects.com/communityCS/TechnicalPapers/rtm_reportingoffadonetdatasets.pdf.asp ).  Once your code adds the image to the dataset, the image would be just another field and the end result should be like reading the image itself directly from the db.

I haven't tried Emre's code so I don't know if it's better or worse than just using a dataset.

frodoman
I dont think you will be able to get refund for that because the answer is posted here to you. When you look at the answer, you will be glad that you didnt have to spend the time that I spent how to find it

Regards
Emre
>>frodoman
My code is also using datasets. There is no other way in .net if you dont embed your image into the database
Regards
Emre
Emre - I hadn't really looked at your link other than to see that you'd posted code / I didn't even read the code itself.  Certainly if that's what you're doing then the specific code is much more relevant than my general comment.  Cheers - frodoman
Not looking for a refund at all. Just the opposite. I very much want you to get the credit!

I haven't had a chance to check the code out yet but will later today. Thanks again! :)
No problem. Glad to help

Regards
Emre
Listen to both frodoman and emre.  Using a dynamic dataset is a good way to go.  Alternately, you can upload the images into a table in your database and simply report from them as another field.
Hi all,

Sorry for not updating this in a couple of days. I gave the info to one of my employees and he couldn't get it implemented. I'm going to give it a try myself over the weekend and let you know if I have any problems/questions. Thanks again for the help.
I still haven't had a chance to re-visit this issue. I've given the suggested solution to two employees and they couldn't make it work. It is coming around to being an important customer issue again so I intend to look into in myself in the next few days.
ASKER CERTIFIED SOLUTION
Avatar of ebolek
ebolek

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
First of all, I'd like to apologize for kind of dropping this when so many people tried to help right away.

I had initially delegated this to two of my employees and they both had problems getting it to work. It was only in the last few days that I was able to spend some time on this myself. I am happy to report that I have successfully implemented the advice to generate my report with images not stored in sql.

I'd like to thank Emre for his suggestions. I had already had the idea of loading the images into a dataset before binding to Crystal but hadn't researched the mechanics involved. Emre's source code saved me some time and effort.

There were a few things I did have to figure out for myself that I'd like to mention for anyone else researching a solution for this problem.

1) I used a type of "xs:base64Binary" for the column in the dataset that was used to design the Crystal Report. (See the PDF tutorial linked by Frodoman above for a good basic example of creating a report based on a dataset.) Crystal saw this column as a BLOB object and allowed me to set picture properties.

2) I didn't add the column the way Emre did in his code. It was already in the dataset that I created. I populated my dataset via an ADO.Net call to a SQL stored procedure that was designed to bring down the image column as null. Then I traversed the rows in the table inside my dataset (with a for loop) and loaded each image into the column record. I bound my now updated dataset to the Crystal Report and was actually surprised by how easy it worked.

Thanks again for everybody's help. This is truly a great website.

If anyone reading this needs help solving the same problem, I'd be happy to provide more specific details.