Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
I have multiple PDF as bytes in database, I want to convert byte to PDF and merge all files in one PDF.

What I have tried:

C#
<pre> private void DocumentFile()
        {
           
            Document document = new Document();
             DataTable dTable = document.GetDocuments();
            if (dTable.Rows.Count > 0)
            {
                foreach (DataRow row in dTable.Rows)
                {
                    string contentType = dTable.Rows[0]["ContentType"].ToString();
                    string extension = dTable.Rows[0]["Extension"].ToString();
                    byte[] content = (byte[])dTable.Rows[0]["Content"];
                    Response.Clear();
                    MemoryStream ms = new MemoryStream(content);
                    Response.ContentType = contentType;
                    Response.AddHeader("Content-Disposition", "attachment; filename=\""
                        + "Doc" + extension + "\"");
                    Response.Buffer = true;
                    ms.WriteTo(Response.OutputStream);
                  
                }
            }

        }
Posted
Updated 4-Jun-23 3:18am

1 solution

You can't just send multiple PDF files sequentially: you would need to combine them into a single PDF.
Google shows the way: Merge pdf files C# - Google Search[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900