1 pièce(s) jointe(s)
ItextSharp: le Texte dans l'image en bas de page
Salut tout le monde,
j'ai un probleme auquel je ne trouve pas de solution. J'utilise Itextsharp pour cree un PDF avec une image en entete et une en bas de page (PdfPageEventHelper), ceci fonctionne a merveille.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| public override void OnEndPage(PdfWriter writer, Document document)
{
base.OnEndPage(writer, document);
if (KundeLogos != null && KundeLogos.LogoFuss != null && KundeLogos.LogoFuss.Length > 0)
{
MemoryStream logoFussStream = new MemoryStream(KundeLogos.LogoFuss);
System.Drawing.Image logoFuss = System.Drawing.Image.FromStream(logoFussStream);
Image imageLogoFuss = Image.GetInstance(logoFuss, new BaseColor(new Color()));
new FooterRenderer(this.Resources, imageLogoFuss, this.KundeLogos.AusrichtungLogoFuss).Render(document, writer, new RenderContext());
}
} |
Et FooterRenderer ajoute la Photo au bas:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| public void Render(Document document, PdfWriter writer, RenderContext context)
{
if (this.FooterImage != null)
{
this.FooterImage.WidthPercentage = 100;
this.FooterImage.SpacingBefore = 50f;
float footerWidth = this.FooterImage.Width;
if (this.FooterImage.Width > document.PageSize.Width * this.footerWidthFactor)
{
this.FooterImage.ScaleToFit(document.PageSize.Width * this.footerWidthFactor, this.FooterImage.Height);
footerWidth = document.PageSize.Width * this.footerWidthFactor;
}
if (this.Position == string.Format("{0}", "Links"))
{
this.FooterImage.SetAbsolutePosition(0, 0);
}
else if (this.Position == string.Format("{0}", "Rechts"))
{
this.FooterImage.SetAbsolutePosition(document.PageSize.Width - footerWidth, 0);
}
else
{
this.FooterImage.SetAbsolutePosition((document.PageSize.Width / 2) - (footerWidth / 2), 0);
}
document.Add(this.FooterImage);
}
} |
Seuleument quand j'ai un long texte que j'ajoute:
Code:
1 2 3 4 5 6 7 8 9 10 11 12
| Paragraph lieferart = new Paragraph { new Phrase(string.Format("{0}: ", ReportDataStrings.ReportData_Lieferart), this.resourceManager.StandardFont), new Phrase(reportData.Lieferart, this.resourceManager.StandardFont) };
lieferart.SpacingAfter = 10f;
unitOfWork.Document.Add(lieferart);
Paragraph textbaustein = new Paragraph();
foreach (ReportTextbausteinData data in textbausteinData)
{
textbaustein.Add(new Paragraph(data.Text, this.resourceManager.StandardFont));
textbaustein.Add(Chunk.NEWLINE);
}
unitOfWork.Document.Add(textbaustein); |
, il est dans l'image comme dans l'image en lien attache. Je vous remercie d'avance.