// output the PDF file
public void print()
{
string tempDir = "";
int fileCount = 0;
// save the image file, get the directory
tempDir = temporaryImageOutput(filePath, ref fileCount);
// link the file to PDF
if (tempDir == "Error")
{
MessageBox.Show("Duplicated file name");
return;
}
Document _pdfDocument = new Document(PageSize.A4, 10, 10, 25, 25);
PdfWriter.GetInstance(_pdfDocument, new FileStream(filePath, FileMode.Create));
_pdfDocument.Open();
// output the PDF
_pdfDocument.Add(new Paragraph(description[0]));
iTextSharp.text.Image imm = iTextSharp.text.Image.GetInstance(tempDir + "\\" + 1 + ".png");
imm.ScaleToFit(PageSize.A5);
_pdfDocument.Add(imm);
for (int i = 2; i <= fileCount; i++)
{
_pdfDocument.NewPage();
_pdfDocument.Add(new Paragraph(description[i - 1]));
iTextSharp.text.Image ima = iTextSharp.text.Image.GetInstance(tempDir + "\\" + i + ".png");
ima.ScaleToFit(PageSize.A5);
_pdfDocument.Add(ima);
}
_pdfDocument.Close();
}