Mam iTextSharp metoda szablon stopki tak:Jak używać znaczników HTML w iTextSharp ciąg
public PdfTemplate footerTemplate(){
PdfTemplate footer = cb.CreateTemplate(500, 50);
footer.BeginText();
BaseFont bf2 = BaseFont.CreateFont(BaseFont.TIMES_ITALIC, "windows-1254", BaseFont.NOT_EMBEDDED);
footer.SetFontAndSize(bf2, 11);
footer.SetColorStroke(BaseColor.DARK_GRAY);
footer.SetColorFill(BaseColor.GRAY);
int al = -200;
int v = 45 - 15;
float widthoftext = 500.0f - bf2.GetWidthPoint(footerOneLine[0], 11);
footer.ShowTextAligned(al, footerOneLine[0], widthoftext, v, 0);
footer.EndText();
return footer;
}
footerTemplate() jest coraz ciąg tak:
footerOneLine.Add("<b>All this line is bold, and <u>this is bold and underlined</u></b>");
i mam inne metoda tworzy łańcuchy znaków do HTML. Metoda jest:
private Paragraph CreateSimpleHtmlParagraph(String text) {
//Our return object
Paragraph p = new Paragraph();
//ParseToList requires a StreamReader instead of just text
using (StringReader sr = new StringReader(text)) {
//Parse and get a collection of elements
List<IElement> elements = iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(sr, null);
foreach (IElement e in elements) {
//Add those elements to the paragraph
p.Add(e);
}
}
//Return the paragraph
return p;
}
Problem: Nie udało się użyć CreateSimpleHtmlParagraph
metodę w powyższych kodów. footer.ShowTextAligned(al, footerOneLine[0], widthoftext, v, 0);
Typy danych metod to footer.ShowTextAligned(int, string, float, float, float);
Czy możesz mi pomóc, jak mogę zastosować metodę CreateSimpleHtmlParagraph
w powyższych kodach? Pozdrawiam.
Czy rzutowanie 'v' i' 0' na 'float' działa? (Tj. 'Footer.ShowTextAligned (al, footerOneLine [0], widthoftext, v jako float, 0 jako float);') – millimoose
Nie widzę zawartości metody ShowTextAligned. Ponieważ jest w itextsharp.ddl. Jaka jest różnica? Nie ma problemu, gdzie mówisz. Metoda ShowTextAligned wymaga napisu w drugim elemencie. Ale metoda CreateSimpleHtmlParagraph zwraca akapit. Nie zarządzałem tą konwersją. –
Przepraszam, chyba nie zrozumiałem wtedy twojego pytania poprawnie. – millimoose