Tarik
Tarik

Reputation: 81841

How to get image path from Resource files

I am storing images in Resource files but the PDF Lib I am using needs image path as string in order to embed images in the output.

But honestly, I couldn't find any way to do that.

Upvotes: 0

Views: 4299

Answers (2)

twoflower
twoflower

Reputation: 6830

You can use Assembly.GetManifestResourceStream(resource_name_of_the_image) to access the image's stream, write it to TEMP directory and use this path.

For example, if you have an image file in your project at the path "Resources\Images\Image.png" and the project's assembly default namespace is "RootNamespace", you can access the image's stream from within this assembly's code with

Assembly.GetExecutingAssembly().GetManifestResourceStream("RootNamespace.Resources.Images.Image.png")

Upvotes: 0

competent_tech
competent_tech

Reputation: 44971

Extract the images to a temporary location on disk, then feed that temporary location to the PDF library.

Upvotes: 1

Related Questions