Free Support Forum -

Error Adding Image From Emedded Resource

I am trying to add an image that I have as an embedded resource to my PDF Document but am getting an error: Value cannot be null. Parameter name: input.

Pdf pdf = new Pdf();

Section section = pdf.Sections.Add();

section.IsLandscape = true;

Image image1 = new Image(section);

Assembly assembly = Assembly.GetExecutingAssembly();

string[] resourceNames = assembly.GetManifestResourceNames();

foreach (string resourceName in resourceNames)


if (resourceName == ResourceName.ImageFile)


Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName);

image1.ImageInfo.ImageStream = stream;




image1.ImageInfo.ImageFileType = ImageFileType.Jpeg;

section.Paragraphs.Add(image1);MemoryStream stream = new MemoryStream();



You method of getting the image stream is not working. Please check to ensure that you the image stream is a valid image stream. I have tested with this code and didn't get any problems.

Pdf pdf = new Pdf();

Aspose.Pdf.Section section = pdf.Sections.Add();

section.IsLandscape = true;

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

MemoryStream ms = new MemoryStream();

Resource1.wernerarrow.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);

image1.ImageInfo.ImageStream = ms;

image1.ImageInfo.ImageFileType = ImageFileType.Jpeg;




After adding a resource file to the project and using the code provided I was able to save my image to the pdf document

Thanks for the help!!!!