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

Free Support Forum - aspose.com

Insert image into PDF

Hi Guys,

I have purchased Aspose.Total already. Now I have 5 different images may be of any extension i.e. tif or jpg or gif etc.

Now I want to insert those into different pdf files and after that want to merge all the PDFs into a single PDF file.

How can I do this?


Hello Munendra,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for considering Aspose.

I am not sure about your requirement when you say "Insert Image into different Pdf files".

Insert Image
a) If you are generating Pdf files from scratch and want to add image into the Pdf files, than use Aspose.Pdf please visit the following link for more information and code snippet Use Image from Local Disk

b) If you need to insert images into already generated Pdf file, please use Aspose.Pdf.Kit and visit http://www.aspose.com/documentation/file-format-components/aspose.pdf.kit-for-.net-and-java/adhere-image.html

Merge Pdf files
In order to merge Pdf files, please use Aspose.Pdf.Kit and visit the following link for related information Concatenate PDF Documents

In case of any further query, please feel free to share.

Hi Nayyer Shahbaz,

Many many thanx for your precious advice.

It helped me a lot. I waqnt the same for my project as u gave to me.

But I have a problem in the concatenation. You gave me the code to concatanate pdf files where we know the counting of files. But when we have to decide the counting of pdf files to be merged at run time, then how can I make an array of filestream object and initialize with file names.

i,.e. I have a directory at c:\. The numbwer of PDF files may be different at different times. Then how can I decide the array of filestream object and initialize thm with file names to be merged.

Can u write a small code for me.

Plz help. Its urgent.

Hello Munendra,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Please refer to the following code snippet. I hope it will help you out, in order to accomplish your requirement. In my case I have 10 files in the same folder. You can adjust the file count by changing the loop variable value in GetDataTable method.


DataTable PDFFiles = GetDataTable();
string[] fileNames = new string[PDFFiles.Rows.Count];
for (int i = 0; i <= (PDFFiles.Rows.Count - 1); i++)

fileNames[i] = PDFFiles.Rows[i].ItemArray[0].ToString();

string masterFileName = "Concatenated.pdf";

Aspose.Pdf.Kit.PdfFileEditor pdfEditor = new PdfFileEditor();
pdfEditor.Concatenate(fileNames, (@"C:\pdftest\") + "\\" + masterFileName);

private DataTable GetDataTable()
DataTable tbl = new DataTable();
DataColumn col = new DataColumn("path");
for (int i = 0; i < 10; i++)
DataRow row = tbl.NewRow();
row["path"] = string.Format(@"C:\pdftest\" + "Copy ({0}) of Sample.pdf", i);
return tbl;