----- Original Message ----- 
From: "Rebecca" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Monday, July 25, 2005 4:10 PM
Subject: [iText-questions] Re: HTMLWorker and ColumnText


> The code you provided does not work for me.  It errors on the document
having
> no pages.  I have to use ct.SetSimpleColumn(document.Left,
document.Bottom,
> document.Left, document.Top) and set ct.YLine = document.Top...I suppose
there
> may be a better combination, but I have not found it. :(
>

That's the way to go.

> I am trying to set the default font by using cb.SetFontAndSize(font,size),
so
> I modified the code as follows...
>

You can't do that. To set a default font put it in the style "body":

stylesheet.LoadStyle("body", "face", "Arial")

You must have the fonts registered in FontFactory.

> Private Sub useHtmlWorker()
>         Dim document As New Document(PageSize.LETTER)
>         Dim fs As New System.IO.FileStream(Server.MapPath("itext5.pdf"),
> IO.FileMode.Create)
>         Dim pdfWriter As iTextSharp.text.pdf.PdfWriter =
> iTextSharp.text.pdf.PdfWriter.GetInstance(document, fs)
>         document.Open()
>         Dim style As html.simpleparser.StyleSheet = createStyleSheet()
>         Dim sr As System.IO.StreamReader = System.IO.File.OpenText
> (System.IO.Path.GetTempPath & "oc2.htm")
>         Dim list As ArrayList =
html.simpleparser.HTMLWorker.ParseToList(sr,
> style)
>         Dim cb As iTextSharp.text.pdf.PdfContentByte =
pdfWriter.DirectContent
>         Dim ct As New iTextSharp.text.pdf.ColumnText(cb)
>         ct.SetSimpleColumn(document.Left, document.Bottom, document.Right,
> document.Top)
>         ct.YLine = document.Top
>         Dim bf As iTextSharp.text.pdf.BaseFont =
> iTextSharp.text.pdf.BaseFont.CreateFont
> (iTextSharp.text.pdf.BaseFont.HELVETICA,
iTextSharp.text.pdf.BaseFont.CP1250,
> False)
>         cb.BeginText()
>         cb.SetFontAndSize(bf, 10)
>         If Not list Is Nothing Then
>             Dim i As Integer
>             For i = 0 To list.Count - 1
>                 Dim e As IElement = CType(list.Item(i), IElement)
>                 ct.AddElement(e)
>                 ct.Go()
>             Next
>         End If
>         cb.EndText()
>         sr.Close()
>         document.Close()
>     End Sub
>
> I seem to be getting the opposite problem that I have been able to find on
the
> newsgroup...
>
>   Illegal operation 'BT' inside text object.
>   Illegal operation 'ET' outside text object.
>
> Is there any way to set the font via the stylesheet for indivual tags or
> classes?  Does loadstyle support alignment?  I can change the text to red,
but
> I can't center it.
>
>   stylesheet.LoadStyle("center", "size", "8px")
>   stylesheet.LoadStyle("center", "align", "right")
>   stylesheet.LoadStyle("center", "color", "#ff0000")
>

That depends on the html context.

> Thanks so much...again...
>
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
> from IBM. Find simple to follow Roadmaps, straightforward articles,
> informative Webcasts and more! Get everything you need to get up to
> speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
> _______________________________________________
> iText-questions mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/itext-questions



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to