We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Fatest Way To Append Image to a PDF File

Can you please help me to know what is fastest way to append multiple image to PDF file.

Currently I am appening 26 Image files (7 mb each) into a single page of PDF File. And it is taking around 3 minutes to process , so is there any way to optimize this processing time?
Below is my code to generate PDF.

Document Doc = new Document(“Temp.pdf”);

            // Create instance of PdfFileMend class
            PdfFileMend mendor = new PdfFileMend(Doc);

            var ImgFiles = Directory.GetFiles("D:\\SampleImages").ToList().Where(x => x.Contains(".png"));

            foreach ( string TF in ImgFiles)

                // Text Fragment
                using (FileStream FS = new FileStream(TF, FileMode.Open))

                    Stream Img = new MemoryStream();

                      mendor.AddImage(Img, 1, 50, 50, 400, 400);


            MemoryStream MS = new MemoryStream();
            Doc.Save(MS, SaveFormat.Pdf);

Machine Configuration:
CPU:Xeon e5-2620 @2.0Ghz
OS : windows 10

Please suggest me some Way outs



Thanks for contacting support.

Can you please share source files along with environment details so that we may further investigate to help you out.