Thank you very much for your kind reply. (I am really new with c# (and programming) and my english doesn't help me.). I have clear what you say but when I try, the program throw an ArgumentOutOfRangeException" in this line and can't understand why.
Code:
private void SaveImage(List<Image> lista)
{
PdfDocument doc = new PdfDocument();
int page = 0;
int imagEnDoc = 0;
MessageBox.Show("Items en lista: " + lista.Count.ToString());
//int i = 0;
while (imagEnDoc < 16)
{
doc.Pages.Add(new PdfPage());
XGraphics xgr = XGraphics.FromPdfPage(doc.Pages[page]);
//ciclo recorre la lista de imégenes y las agrega al documento
int i = 0;
while (i < lista.Count)
{
int coordY = 60;
int posY = 1;
while (posY < 5)
{
int coordX = 40;
int posX = 1;
while (posX < 5)
{
if (imagEnDoc == lista.Count) break;
XImage imgToPdf = XImage.FromGdiPlusImage(lista[i]);
double height = imgToPdf.PixelHeight * 0.35;
double width = imgToPdf.PixelWidth * 0.35;
xgr.DrawImage(imgToPdf, coordX, coordY, width, height);
imagEnDoc++;
i++;
posX++;
coordX = coordX + 120;
//MessageBox.Show("Foto en documento: " + coordX.ToString() + ", " + coordY.ToString());
}
posY++;
coordY = coordY + 150;
}
page++;
imagEnDoc = 0;
}
}