Convert Image to pdf
Code for how to convert a image to pdf
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Rajeesh MenothRank #118 · 18.4K reputationPosted Apr 6, 2017, 3:16 AM EDT
Ranjeet PatraRank #1,436 · 1.1K reputationPosted Apr 6, 2017, 4:33 AM EDT
Sidhartha PatnaikRank #5,346 · 302 reputationPosted Apr 6, 2017, 4:51 AM EDT
Rajeesh sir,
Sidhartha PatnaikRank #5,346 · 302 reputationPosted Apr 6, 2017, 4:51 AM EDT
Uehara AyakaRank #2,730 · 512 reputationPosted Apr 6, 2017, 6:10 PM EDT
alice yangRank #2,329 · 607 reputationPosted Apr 6, 2017, 6:13 PM EDT
Hussam BarouqaRank #6,374 · 268 reputationPosted Apr 13, 2017, 7:14 AM EDT
The most direct approach you could consider is to convert the HTML page into a rasterized image then save it as a PDF. This will maintain the overall design and images in the page. If you want to also keep text selectable after doing this, you could perform OCR on the result.
To convert an HTML page into PDF, there is .NET code you can implement as a service:
RasterCodecs codecs = new RasterCodecs();
codecs.convert("input.html", "output.pdf", RasterImageFormat.RasPdfJpeg411, 0, 0, 0, null);
If you want to maintain the text during conversion, another thing you can try is the DocumentConverters class:
using (DocumentConverter documentConverter = new DocumentConverter())
{
var format = DocumentFormat.Pdf;
var jobData = DocumentConverterJobs.CreateJobData(inFile, outFile, format);
jobData.JobName = "conversion job";
var job = documentConverter.Jobs.CreateJob(jobData);
documentConverter.Jobs.RunJob(job);
}
Check out this forum topic for more features that can be implemented with ASP.NET MVC, including OCR:
https://www.leadtools.com/support/forum/posts/m41793-HTML5-Projects-with-ASP-NET#post41793