I need help converting a Stream into a PDF document, in my C#.Net Windows Service

Hello Experts:

1. I need help converting a Stream into a PDF document, in my C#.Net Windows Service.
2. I need to save the newly created PDF document into the following location:  C:\MyClaims\

Here my current code.  I have a Stream variable named mergeClaims, which i need to create into a PDF doc.

                if (_rejectLetter.Count() > 0)
                {
                    foreach (var r in _rejectLetter)
                    {
                        int cdo =  r.CDO.Value;
                        long MisdirectedID = r.MisdirectedID;
                        string market = r.Market.ToString();
                        string healthplan = r.HealthPlan.ToString();
                        string GROUP_ID = r.GROUP_ID.ToString();
                        string runType = r.RunType.ToString();
                        string dcn = r.Intermediary_Claim_Number.ToString();
                        string ClaimType = r.ClaimType.ToString();

                        Utilities.GenerateMisdirectedLetter ltr = new GenerateMisdirectedLetter();
                        Stream coverLetter = ltr.CreateMisdirectedLetter(cdo, market, healthplan, runType);
                        new Utilities.DB(connRejLetter).insertMisdirectedPrintDate(MisdirectedID);

                        Utilities.getClaimForm claim = new Utilities.getClaimForm();
                        Stream Claim = new MemoryStream();
                        Claim = claim.ExportForm(dcn, ClaimType, true);

                        List<Stream> claims = new List<Stream>();
                        claims.Add(coverLetter);
                        claims.Add(Claim);
                        Stream mergeClaims = _pdf.mergePDFs(claims);  //NEED TO CONVERT THIS STREAM INTO A PDF
                    }
                }

Open in new window

mainrotorAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chinmay PatelChief Technical NinjaCommented:
What is the data in the stream? is it just text? or HTML? Also it seems you already have pdf generation ability (_pdf object), can you clarify a bit on the scenario you are trying to handle?

You can always use https://sourceforge.net/projects/itextsharp/ to generate PDFs from stream but some clarity on the background of your issue will really help.
0
Shaun VermaakTechnical Specialist/DeveloperCommented:
Can you not run this?
Claim.CopyTo(file);

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.