Use image from the Resources C # folder

0

I need to use an image (x.png) from the Resources folder of the solution to enter it into a .PDF using the NuGet iTextSharp (v5.5.13).

Normally I would load it like this, in case of being an address of the machine.

iTextSharp.text.Image tif = iTextSharp.text.Image.GetInstance("C:\Users\Lelo-Magdiel\Desktop\x.png");

Is it possible? How can I do it?

A thousand thanks in advance.

    
asked by Magdiel Hernandez 14.09.2018 в 05:30
source

2 answers

0

Try the following (convert the image into an array of bytes, then get its instance, to finish adding it to the document:

byte[] bytesImagen = new system.Drawing.ImageConverter().ConvertTo(Resources.X, typeof(byte[])) as byte[];
Image imagen = Image.GetInstance(bytesImagen);
document.add(image);
    
answered by 15.09.2018 / 18:44
source
0

Assuming you have the image in the Resources of the same project, it would look something like this:

iTextSharp.text.Image tif = iTextSharp.text.Image.GetInstance(Resources.Foto, System.Drawing.Imaging.ImageFormat.Png);

Where Foto is the name of the image that you assigned when you added it to Resources .

Greetings and I hope I can help you.

    
answered by 14.09.2018 в 05:59