Free Support Forum - aspose.com

Error in writing image to a pdf file

hi,

i am getting "object reference not set to an instance of an object" error while writing that to pdf file

i am giving you the code also.please tell me the solution for this.

code:

Pdf pdf1 = new Pdf();

System.IO.FileStream fs = new System.IO.FileStream("C:/dwclogo1.jpg",System.IO.FileMode.Open);

Section sec1 = pdf1.Sections.Add();

Aspose.Pdf.Image image1 = new Aspose.Pdf.Image(sec1);

sec1.Paragraphs.Add(image1);

image1.ImageInfo.File = "c:/dwclogo1.jpg";

image1.ImageInfo.ImageFileType = ImageFileType.Jpeg;

image1.ImageInfo.Title = "JPEG image";

pdf1.Save("c:\test.pdf");

fs.Close();

Please let me know the answer for this question ASAP.

thanks in advance.

Thanks for considering Aspose.

Please del the second line that new a FileStream and run again.