In This Topic
Programming / Document Conversion / Combining different file formats to PDF in a single line of code

Combining different file formats to PDF in a single line of code

In This Topic

Combining several documents of different formats to a single PDF document is often required. GdPicture.NET allows you to convert a wide variety of formats, which are listed here. The GdPictureDocumentConverter class enables this feature in a quick and easy "single line of code" operation. In addition, you can choose the PDF conformance level of the resulting PDF document. Here is the fundamental workflow you need to follow.

Copy Code
'We assume that GdPicture has been correctly installed and unlocked.
Dim inputFiles As IEnumerable(Of String) = New List(Of String)(New String() {"d:\image.jpg", "d:\document.pdf", "d:\image.tif", "d:\todo_list.xlsx"})
Using dstStream As Stream = File.Create("d:\merged.pdf")
    Using gdpictureDocumentConverter As GdPictureDocumentConverter = New GdPictureDocumentConverter()
        gdpictureDocumentConverter.CombineToPDF(inputFiles, dstStream, PdfConformance.PDF1_5)
    End Using
End Using
Copy Code
//We assume that GdPicture has been correctly installed and unlocked.
IEnumerable<string> inputFiles = new List<string>(new string[] { "d:\\image.jpg", "d:\\document.pdf", "d:\\image.tif", "d:\\todo_list.xlsx" });
using (Stream dstStream = File.Create("d:\\merged.pdf"))
{
    using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
    {
        gdpictureDocumentConverter.CombineToPDF(inputFiles, dstStream, PdfConformance.PDF1_5);
    }
}