本文整理汇总了C#中iTextSharp.text.List.ForEach方法的典型用法代码示例。如果您正苦于以下问题:C# List.ForEach方法的具体用法?C# List.ForEach怎么用?C# List.ForEach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类iTextSharp.text.List
的用法示例。
在下文中一共展示了List.ForEach方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CompareImageFromPdf
public ReadOnlyCollection<double> CompareImageFromPdf(string path, string testImage)
{
List<double> match = new List<double>();
List<System.Drawing.Image> ImgList = new List<System.Drawing.Image>();
ImgList = GetImages(path);
ImgList.ForEach(img => img.Save("Image_" + Guid.NewGuid() + ".bmp"));
ImgList.ForEach(img => match.Add(ImageTest(testImage, img)));
return match.AsReadOnly();
}
示例2: BodyTabelaComissao
private static string BodyTabelaComissao(List<Pagamento> listaPagamento)
{
var tbody = new StringBuilder();
listaPagamento.ForEach(p =>
tbody.AppendFormat(" <tr><td>{0}</th><td>{1}</th><td>{2}</th><td>{3}</th></tr>"
,p.Contrato.Cliente.Nome
,p.ValorPago
,p.ValorPago - ((p.ValorPago * p.Contrato.Vendedor.Comissao) / 100)
,(p.ValorPago * p.Contrato.Vendedor.Comissao) / 100)
);
return tbody.ToString();
}
示例3: Invoice
public HttpResponseMessage Invoice(string date, string number, string total, string emails, string clientNumber, string matter, string description)
{
byte[] pdf = null;
using (var ms = new MemoryStream())
{
using (var doc = new Document())
{
doc.SetMargins(60, 60, 40, 40);
PdfWriter.GetInstance(doc, ms);
doc.Open();
#region Header
var table = new PdfPTable(4) { WidthPercentage = 100 };
var colSizes = new List<float> { 120f, 130f, 140f };
colSizes.Add(doc.PageSize.Width - colSizes.Sum());
table.SetWidths(colSizes.ToArray());
table.AddCell(new PdfPCell
{
Image = Image.GetInstance(HttpContext.Current.Request.MapPath("~\\App_Data\\Logo.jpg")),
BorderColorRight = BaseColor.WHITE,
Rowspan = 3
});
table.AddCell(new PdfPCell(CreatePhrase("950 E. State Hwy 114\nSuite 160\nSouthlake, TX 76092"))
{
HorizontalAlignment = Element.ALIGN_CENTER,
VerticalAlignment = Element.ALIGN_MIDDLE,
Rowspan = 3
});
table.AddCell(CreateCell("Invoice Date", Element.ALIGN_RIGHT));
table.AddCell(CreateCell(date, Element.ALIGN_CENTER));
table.AddCell(CreateCell("Invoice Number", Element.ALIGN_RIGHT));
table.AddCell(CreateCell(number, Element.ALIGN_CENTER));
table.AddCell(CreateCell("Invoice Total", Element.ALIGN_RIGHT));
table.AddCell(CreateCell(total, Element.ALIGN_CENTER));
doc.Add(table);
#endregion
#region Emails
doc.Add(CreatePhrase(" "));
table = new PdfPTable(1) { WidthPercentage = 100 };
table.AddCell(CreateCell($"Invoice for {emails}", Element.ALIGN_CENTER));
doc.Add(table);
#endregion
#region Matters
doc.Add(CreatePhrase(" "));
table = new PdfPTable(4) { WidthPercentage = 100 };
colSizes = new List<float> { 120f, 130f, 80f };
colSizes.Insert(2, doc.PageSize.Width - colSizes.Sum());
table.SetWidths(colSizes.ToArray());
var columns = new List<string> { "Client", "Matter", "Description", "Amount" };
columns.ForEach(c =>
{
var cell = new PdfPCell
{
Phrase = CreatePhrase(c, headerFont),
HorizontalAlignment = Element.ALIGN_CENTER
};
table.AddCell(cell);
});
columns = new List<string> { clientNumber, matter, description, total };
columns.ForEach(c =>
{
table.AddCell(CreateCell(c, Element.ALIGN_CENTER));
});
doc.Add(table);
#endregion
#region Footer
doc.Add(CreatePhrase("\nIf you have any questions, please contact us at [email protected]\n"));
doc.Add(CreatePhrase("\nThank you for using SyncIDS.com!"));
#endregion
}
pdf = ms.ToArray();
}
var response = new HttpResponseMessage(HttpStatusCode.OK);
response.Content = new ByteArrayContent(pdf);
response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/pdf");
return response;
}
示例4: Merge
//99% of credit goes to this person: http://stackoverflow.com/a/20491695
public static bool Merge(List<string> fullFilePaths, string saveAs)
{
try
{
using (FileStream stream = new FileStream(saveAs, FileMode.Create))
using (Document doc = new Document())
using (PdfCopy pdf = new PdfCopy(doc, stream))
{
doc.Open();
PdfReader reader = null;
PdfImportedPage page = null;
fullFilePaths.ForEach(file =>
{
using (reader = new PdfReader(file))
{
for (int i = 0; i < reader.NumberOfPages; i++)
{
page = pdf.GetImportedPage(reader, i + 1);
pdf.AddPage(page);
}
pdf.FreeReader(reader);
}
});
}
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
return false;
}
return true;
}
示例5: Merge
public static bool Merge(List<PDFFiles> InFiles, string OutFile)
{
try
{
for(int i=0; i<InFiles.Count; i++)
{
PdfReader reader = null;
reader = new PdfReader(InFiles[i].filePath);
if (!reader.IsOpenedWithFullPermissions)
{
string newUnlockedFile = unlockPDF(InFiles[i].filePath); //throw new System.IO.FileLoadException("Cannot merge because \"" + file.fileName + "\" is Locked for editing");
InFiles.Remove(InFiles[i]);
InFiles.Insert(i, new PDFFiles(newUnlockedFile));
}
}
}
catch (FileNotFoundException ex)
{
throw ex;
}
catch (System.IO.FileLoadException)
{
throw;
}
catch
{
return false;
}
try
{
using (FileStream stream = new FileStream(OutFile, FileMode.Create))
using (Document doc = new Document(PageSize.A4))
using (PdfCopy pdf = new PdfCopy(doc, stream))
{
doc.Open();
PdfReader reader = null;
PdfImportedPage page = null;
//fixed typo
InFiles.ForEach(file =>
{
reader = new PdfReader(file.filePath);
for (int i = 0; i < reader.NumberOfPages; i++)
{
page = pdf.GetImportedPage(reader, i + 1);
//doc.SetPageSize(page.Width <= page.Height ? PageSize.A4 : PageSize.A4.Rotate());
pdf.AddPage(page);
}
pdf.FreeReader(reader);
reader.Close();
});
}
}
catch
{
return false;
}
ScaleToA4(OutFile, OutFile);
return true;
}