Tutorial: Create a Multipage File from Multiple Images

There are many files that exist in the workplace that are multiple pages long. Having the ability to load, split, and extract is a vital need of many applications. Some of the most common multipage file types are: PDF, TIFF, and Microsoft Office formats such as Docx, Doc, Xls, and Xlsx. LEADTOOLS supports all of these as well as over 30 other multipage formats. Since there are so many different types of multipage formats, it can be a headache trying to support the common ones and a nightmare trying to support them all. Luckily, the LEADTOOLS SDK can get this app done in less than five lines of code.

The other day I was assisting a client who was writing an application to accept scans of receipts into their document management system. Most of their customers used mobile phones to scan the receipts and phones generally export photos as JPG or PNG which are single page formats. They wanted to combine all the images sent in from the same customer on the same day into a single PDF. I mentioned how he can use the Save Method from the RasterCodecs class to save multiple single page files to the same output. He was able to use this and create a working solution in no time. With the LEADTOOLS Imaging libraries, developers can quickly create applications like this in less than five minutes.

Below is the basic code for creating a multipage file from individual files. If you want to view a complete step-by-step tutorial on the LEADTOOLS documentation, see the “Create a Multipage File from Multiple Images”.

// Create Multipage File out of Single Files
string[] files = System.IO.Directory.GetFiles(@"C:\Users\Public\Documents\LEADTOOLS Images", "*.cmp");

using (RasterCodecs codecs = new RasterCodecs())
	foreach (var file in files)
   		using (RasterImage image = codecs.Load(file))
       		codecs.Save(image, outputFile, RasterImageFormat.TifJpeg411, 0, 1, -1, 1, 
       		CodecsSavePageMode.Append);	

Try it out!

To test this for yourself, make sure to get the latest LEADTOOLS SDK code for free straight from our site if you have not already. This trial is good for 60 days and comes with unlimited chat and email support.

Support

Need help getting this sample up and going? Contact our support team for free technical support! For pricing or licensing questions, you can contact our sales team (sales@leadtools.com) or call us at 704-332-5532.


Stay tuned for more paperless office related blog post like this one. Our previous post talked about how to quickly load and save images, so make sure to check that one out! We’ll be featuring a lot more tutorials that programmers can use to develop applications that will directly impact data capture, recognition, exchange, and other pressing business needs.

About 

Developer Support Manager

This entry was posted in General Imaging. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *