Download the source, and try replacing the method in the attachment and
rebuilding the solution.
I think the problem is that for ordered lists you need to set the List's
Autoindent property to true. The only changes in the attachment are:
Move the List's `Alignindent` and `Autoindent` defaults (false) to the top of
the method. (to lines 7/8)Set the List's `Autoindent` property to true for
numbered lists (line 17)
Just a quick look at the source code and only tested for this specific case. So
this may not be the perfect fix, but it should get you started. Paulo just
released iTextSharp 5.1.3 this weekend (THANK YOU!), so it may be a while
before the .NET version of XML Worker 1.1.1 or any other changes are done.
HTH - keith
Date: Tue, 29 Nov 2011 13:58:44 -0500
From: stephenmb...@gmail.com
To: itext-questions@lists.sourceforge.net
Subject: Re: [iText-questions] HTML to PDF - XMLWorker Ordered Lists?!?
Thanks for the response. An explanation eventually would be pretty sweet. I
will continue to look for a workaround, short of hard coding the numbering in
the html.
On Tue, Nov 29, 2011 at 1:51 PM, Balder VC <li...@redlab.be> wrote:
It's easily reproduced. It could be a bug.
Can't explain what's happening, yet. Don't have time right know.
On 27/11/2011 19:39, Stephen Bell wrote:
I am looking to convert the generated HTML output from
an ASPX page to a PDF file. I have this "sort of" working using
the XMLWorker. The ASPX / HTML page that I am looking to convert
has an orderd list on it - what I am seeing is for list items 1-9
everything comes out perfect. Once I get to double digits -
greater than 10 - the trailing period after 10. , 11., 12., etc is
not present and the spacing is not correct.
The line of code that is doing the conversion for me is simply :
GetInstance().ParseXHtml(writer, doc, New StringReader(markup)) -
where the markup variable is a string of the generated HTML.
Can anyone explain why this is happening and what I need to do to
fix the output?
Thanks
sb
Regards
Balder
--
twitter
redlab-log
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php
public List Apply(List list, Tag t, HtmlPipelineContext
htmlPipelineContext) {
float fontSize = FontSizeTranslator.GetInstance().GetFontSize(t);
List lst = list;
IDictionary<String, String> css = t.CSS;
String styleType;
css.TryGetValue(CSS.Property.LIST_STYLE_TYPE, out styleType);
lst.Alignindent = false;
lst.Autoindent = false;
if (null != styleType) {
if (Util.EqualsIgnoreCase(styleType, CSS.Value.NONE)) {
lst.Lettered = false;
lst.Numbered = false;
lst.SetListSymbol("");
} else if (Util.EqualsIgnoreCase(CSS.Value.DECIMAL, styleType))
{
lst = new List(List.ORDERED);
SynchronizeSymbol(fontSize, lst);
lst.Autoindent = true;
} else if (Util.EqualsIgnoreCase(CSS.Value.DISC, styleType)) {
lst = new ZapfDingbatsList(108);
ShrinkSymbol(lst, fontSize);
} else if (Util.EqualsIgnoreCase(CSS.Value.SQUARE, styleType)) {
lst = new ZapfDingbatsList(110);
ShrinkSymbol(lst, fontSize);
} else if (Util.EqualsIgnoreCase(CSS.Value.CIRCLE, styleType)) {
lst = new ZapfDingbatsList(109);
ShrinkSymbol(lst, fontSize);
} else if (CSS.Value.LOWER_ROMAN.Equals(styleType)) {
lst = new RomanList(true, 0);
SynchronizeSymbol(fontSize, lst);
} else if (CSS.Value.UPPER_ROMAN.Equals(styleType)) {
lst = new RomanList(false, 0);
SynchronizeSymbol(fontSize, lst);
} else if (CSS.Value.LOWER_GREEK.Equals(styleType)) {
lst = new GreekList(true, 0);
SynchronizeSymbol(fontSize, lst);
} else if (CSS.Value.UPPER_GREEK.Equals(styleType)) {
lst = new GreekList(false, 0);
SynchronizeSymbol(fontSize, lst);
} else if (CSS.Value.LOWER_ALPHA.Equals(styleType) ||
CSS.Value.LOWER_LATIN.Equals(styleType)) {
lst = new List(List.ORDERED, List.ALPHABETICAL);
SynchronizeSymbol(fontSize, lst);
lst.Lowercase = true;
} else if (CSS.Value.UPPER_ALPHA.Equals(styleType) ||
CSS.Value.UPPER_LATIN.Equals(styleType)) {
lst = new List(List.ORDERED, List.ALPHABETICAL);
SynchronizeSymbol(fontSize, lst);
lst.Lowercase = false;
}
} else if (Util.EqualsIgnoreCase(t.Name, HTML.Tag.OL)) {
lst = new List(List.ORDERED);
SynchronizeSymbol(fontSize, lst);
} else if (Util.EqualsIgnoreCase(t.Name, HTML.Tag.UL)) {
lst = new List(List.UNORDERED);
ShrinkSymbol(lst, fontSize);
}
if (css.ContainsKey(CSS.Property.LIST_STYLE_IMAGE)
&&
!Util.EqualsIgnoreCase(css[CSS.Property.LIST_STYLE_IMAGE], CSS.Value.NONE)) {
lst = new List();
String url =
utils.ExtractUrl(css[CSS.Property.LIST_STYLE_IMAGE]);
iTextSharp.text.Image img = null;
try {
if (htmlPipelineContext == null) {
img = new ImageRetrieve().RetrieveImage(url);
} else {
try {
img = new
ImageRetrieve(htmlPipelineContext.GetImageProvider()).RetrieveImage(url);
} catch (NoImageProviderException) {
if (LOG.IsLogging(Level.TRACE)) {
LOG.Trace(String.Format(LocaleMessages.GetInstance().GetMessage("pipeline.html.noimageprovider"),
htmlPipelineContext.GetType().FullName));
}
img = new ImageRetrieve().RetrieveImage(url);
}
}
lst.ListSymbol = new Chunk(img, 0, 0, false);
lst.SymbolIndent = img.Width;
if (LOG.IsLogging(Level.TRACE)) {
LOG.Trace(String.Format(LocaleMessages.GetInstance().GetMessage("html.tag.list"),
url));
}
} catch (IOException e) {
if (LOG.IsLogging(Level.ERROR)) {
LOG.Error(String.Format(LocaleMessages.GetInstance().GetMessage("html.tag.list.failed"),
url), e);
}
lst = new List(List.UNORDERED);
} catch (NoImageException e) {
if (LOG.IsLogging(Level.ERROR)) {
LOG.Error(e.Message, e);
}
lst = new List(List.UNORDERED);
}
}
float leftIndent = 0;
if (css.ContainsKey(CSS.Property.LIST_STYLE_POSITION) &&
Util.EqualsIgnoreCase(css[CSS.Property.LIST_STYLE_POSITION], CSS.Value.INSIDE))
{
leftIndent += 30;
} else {
leftIndent += 15;
}
leftIndent +=
css.ContainsKey(CSS.Property.MARGIN_LEFT)?utils.ParseValueToPt(css[CSS.Property.MARGIN_LEFT],fontSize):0;
leftIndent +=
css.ContainsKey(CSS.Property.PADDING_LEFT)?utils.ParseValueToPt(css[CSS.Property.PADDING_LEFT],fontSize):0;
lst.IndentationLeft = leftIndent;
return lst;
}
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php