Click here to Skip to main content
15,891,657 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a Byte array that contains image base 64, How I can convert this to Pdf byte array in C#?

This is my code:


So content contains byte array of image 64, I need to convert this to byte array that is pdf.

This method should be there (ToImageAsync) as I need to convert to image first to keep my css if I convert there to PDF it is not working, So before having it in response to need to convert to pdf byte array.



What I have tried:

<pre>
var pdfTemplate = Regex.Replace(template.Content, @"\t|\n", string.Empty);

            var imageResponse = await ToImageAsync(new HtmlConverterRequest
            {
                Html = template.Content,
                Height = 1000,
                Width = 1500
            });
            content = imageResponse.Content;
        }
        return new GetResponse
        {
            image =   content
        };
Posted
Updated 9-Nov-20 14:14pm

1 solution

Quote:
How to convert an image (jpg that is in byte array base 64) to a .PDF(in byte array) in C#

First, do yourself a favor and stop combining problems into super problems, rather split problems.
A jpg encoded in base64 is only for your convenience.
- Convert base64 image back to original byte stream, and may be save it as file depending on tool that will convert to pdf.
- then convert to pdf.
It will be much easier than looking for a tool that do exactly what you need.
 
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