Private sub useHtmlWorker()
  Dim document As New Document(PageSize.A4)
  Dim fs As New System.IO.FileStream(System.IO.Path.GetTempPath
& "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, 0, document.Right, 24)
  ct.YLine = 24
  If Not list Is Nothing Then
    Dim i As Integer
    For i = 0 To list.Count - 1
      ct.AddElement(CType(list.Item(i), IElement))
      ct.Go()
    Next
  End If
  sr.Close()
  document.Close()
End Sub


----- Original Message ----- 
From: "Rebecca" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Friday, July 22, 2005 8:13 PM
Subject: [iText-questions] HTMLWorker and ColumnText


> Can someone explain how to use HtmlWorker and ColumnText?
>
> > PdfContentByte cb = pdfWriter.getDirectContent();
> >
> > ColumnText ct = new ColumnText(cb);
> > ct.setSimpleColumn(...);
> > ct.setYLine(...);
> > if (list != null) {
> >   for (int i=0; i < list.size(); i++) {
> >     ct.addElement((Element)list.get(i));
> >   }
> > }
> > ct.go();
>
>
> I'm using vb.net so here is my code
> Private sub useHtmlWorker()
>   Dim document As New Document(PageSize.A4)
>   Dim fs As New System.IO.FileStream(System.IO.Path.GetTempPath
> & "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, 0, document.Right, 24)
>   ct.YLine = 1
>   If Not list Is Nothing Then
>     Dim i As Integer
>     For i = 0 To list.Count - 1
>       ct.AddElement(CType(list.Item(i), IElement))
>       ct.Go()
>       ct.YLine += 1
>     Next
>   End If
>   sr.Close()
>   document.Close()
> End Sub
>
> If I move the ct.Yline += 1 and/or the ct.Go lines around (remove yline,
move
> go outside of loop like you had, I get that the document has no pages.  as
it
> is, my lines are written on top of each other; some of them are fine
though.)
>
> I'd appreciate any pointers, thanks so much!
>
>
>
> -------------------------------------------------------
> 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