Can I Converting Jpg image to PDF document?

back to home  >  Tech FAQ  >  Translate JPG Image to PDF document in C#?

Question:

Hi, I want to load some jpeg images and convert them to a new PDF file in my .net project. Do you have a solution for this? Or is it possible for adding jpeg images to an existed PDF file? Any code is appreciated.

---- Lewis

Answer:

Hi, Lewis.

Our pqScan Image to PDF Library can resolve it for you. It supports to turn a list of jpg images to either a new PDF document of a made-ready PDF document in your .net project. What's more, no matter the jpeg image is compressed or not, our .net image to PDF control can distinguish the jpg graphics, and render this image graphs to a individual PDF page.

In the following C# code, we provide two examples to explain.

using System;
using System.Drawing;
using PQScan.ImageToPDF;

namespace ImageToPDFQuestion
{
    class Program
    {
        static void Main(string[] args)
        {
            passToNewPDF();
            passToExistedPDF();
        }
        private static void passToNewPDF()
        {
            //create a PDF converter object.
            PDFConverter pdfConverter = new PDFConverter();

            //add a jpeg image to translating image list.
            string[] jpgImage = new string[1] { "sample.jpg" };           

            //set a name to a new pdf file.
            string fileName = "result.pdf";

            //convert jpg images to a new PDF document.
            pdfConverter.CreatePDF(jpgImage, fileName);

        }
        private static void passToExistedPDF()
        {
            //create a PDF converter object.
            PDFConverter pdfConverter = new PDFConverter();

            //add a jpeg image to translating image list.
            string[] jpgImage = new string[1] { "sample1.jpg" };

            //navigate to an existed pdf file.
            string fileName = "result1.pdf";

            //add jpg image to a existed pdf file.
            pdfConverter.AppendToPDF(jpgImage, fileName);
        }

    }
}

Hope the C# code can be helpful.

---- pqScan Support Team

Online Demo Download Trial How to Encode QR Code with Chinese Words in C# ? How to Insert Barcode Control to MS Excel WorkSheetin C# ? How to Add Barcode Image to MS Excel in C# ? How can I Create Barcode to Crystal Report in Visual Studio ? Can I Read Barcode in PDF document using C#? Can I Get a Compression Jpeg Image from PDF ? Merge A Group of Multi-page Tiff to PDF documentusing C#? Convert specific pages from PDF to images in C# Is it available for reading all of the barcode in a picture by one time? Do You Support Translate Images to PDF from SQL Database? Question about Image Size.