Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8504701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:06:34+00:00 2026-06-11T02:06:34+00:00

I have this little script that generate a table in a .pdf file, but

  • 0

I have this little script that generate a table in a .pdf file, but the text is too big. How do I add another font size/type for it?

Dim form As New HtmlForm

form.Controls.Add(gvEvents)
Dim sw As New StringWriter
Dim htmlWriter As New HtmlTextWriter(sw)
Dim htmlContent As String = sw.ToString()

Response.ContentType = "application/pdf"
Response.AddHeader("content-disposition", "attachment;filename=Holdkalender.pdf")
Response.Cache.SetCacheability(HttpCacheability.NoCache)

form.Controls(0).RenderControl(htmlWriter)
Dim sr As New StringReader(sw.ToString())
Dim pdfDoc As New Document(PageSize.A4, 50, 50, 50, 50)
Dim htmlparser As New HTMLWorker(pdfDoc)
PdfWriter.GetInstance(pdfDoc, Response.OutputStream)
pdfDoc.Open()
htmlparser.Parse(sr)
pdfDoc.Close()
Response.Write(pdfDoc)
Response.End()

EDIT:

I have tried this, but it gives me an Ielement Error:

Protected Sub btnGeneratePDF_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnGeneratePDF.Click
BindEvents(Convert.ToInt32(ddlEventSize.SelectedValue))
Dim form As New HtmlForm

form.Controls.Add(gvEvents)
Dim sw As New StringWriter
Dim htmlWriter As New HtmlTextWriter(sw)
Dim htmlContent As String = sw.ToString()
Response.ContentType = "application/pdf"
Response.AddHeader("content-disposition", "attachment;filename=Holdkalender.pdf")
Response.Cache.SetCacheability(HttpCacheability.NoCache)

form.Controls(0).RenderControl(htmlWriter)
Dim sr As New StringReader(sw.ToString())
Dim pdfDoc As New Document(PageSize.A4, 50, 50, 50, 50) 'Paper Size and margin
Dim htmlparser As New HTMLWorker(pdfDoc)
PdfWriter.GetInstance(pdfDoc, Response.OutputStream)
pdfDoc.Open()
Dim ftlbl As Font = Nothing
ftlbl = FontFactory.GetFont(FontFactory.HELVETICA, 5)
pdfDoc.Add(ftlbl)
Try
    htmlparser.Parse(sr)
Catch ex As Exception
    'Display parser errors in PDF.
    Dim paragraph As New Paragraph("FEJL!" + ex.Message)
    Dim text As Chunk = TryCast(paragraph.Chunks(0), Chunk)
    If text IsNot Nothing Then
        text.Font.Color = BaseColor.RED
    End If
    pdfDoc.Add(paragraph)
Finally
    pdfDoc.Close()
    Response.Write(pdfDoc)
    Response.End()
End Try

End Sub

EDIT 2:

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T02:06:35+00:00Added an answer on June 11, 2026 at 2:06 am

    You can use something like this to give format to your table titles

    EDIT

    //add a Paragraph to the document with an specify format
     Dim TableFont   = FontFactory.GetFont("Arial", 12, Font.BOLD)
    
     pdfDoc.Open()  
     pdfDoc.Add(New Paragraph(sr.ReadToEnd(),TableFont)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this little script that shows one wisdom each day. so I have
So I have this php script that output an html table with data about
So I have this neat little javascript function that I'm using to print text
This is a little tricky so bear with me: I have a PHP script
I have this little problem, that I cannot figure out which arguments to pass
I have this little question that's been on my mind for a while now.
I have this little text <div> Hello world<br> this is a good<br> text! <br><br>
I have this nice little MSBuild-based daily build setup that I use on my
I have a PHP script that will generate a report using PHPExcel from data
I have wrote this little script which generates a nice random password. The problem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.