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

  • SEARCH
  • Home
  • 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 6621457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:16:01+00:00 2026-05-25T21:16:01+00:00

Using this below Code i am Abel to convert a HTML text To PDF

  • 0

Using this below Code i am Abel to convert a HTML text To PDF and my code can generate PDF File on particular location . but problem is…… i give font style in body tags so when PDF is generate i am not getting this font style effect in generate PDF ex.

 // Here On Body Tag I have given a Zurich BT font style
 StyleSheet styles = new StyleSheet();
 //styles.loadTagStyle("body", "font-family", "Zurich BT");
 styles.loadTagStyle("body", "font", "Zurich BT");

so here my font style is Zurich BT but i have just got plane simple text on generate PDF not get any effect on text.

i am using itextpdf-5.1.1 version and my code is….

            ByteArrayOutputStream baos = new ByteArrayOutputStream();   
            Document pdfDocument = new Document();

            Reader htmlreader = new StringReader("<html><head></head><body>"
                    + " <font> HELLO MY NAME IS JIMIT TANK </font> </html></body>");

            PdfWriter.getInstance(pdfDocument, baos);

            pdfDocument.open();

            // Here On Body Tag I am giving a Zurich BT font style
            StyleSheet styles = new StyleSheet();
            //styles.loadTagStyle("body", "font-family", "Zurich BT");
            styles.loadTagStyle("body", "font", "Zurich BT");

            ArrayList arrayElementList =    HTMLWorker.parseToList(htmlreader,styles);

            for (int i = 0; i < arrayElementList.size(); ++i) {
                Element e = (Element) arrayElementList.get(i);
                pdfDocument.add(e);
            }
            pdfDocument.close();
            byte[] bs = baos.toByteArray();
            String pdfBase64 = Base64.encodeBytes(bs); //output
            File pdfFile = new File("c:/pdfExample.pdf");
            FileOutputStream out = new FileOutputStream(pdfFile);
            out.write(bs);
            out.close();
  • 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-05-25T21:16:02+00:00Added an answer on May 25, 2026 at 9:16 pm

    Use iTextSharp Paragraph class and set font and style to it like this

    Document doc = new Document(PageSize.A4);
    Paragraph paraReportTitle = new Paragraph();
                    //paraReportTitle.Font = new Font(Font.FontFamily.HELVETICA, 13f, Font.BOLD);
                    paraReportTitle.Font = new Font(Font.FontFamily.HELVETICA, 8f, Font.NORMAL);
    
    doc.Add(paraReportTitle);
    

    Setting style to html will not work.

    You can also use the BaseFont class in iTextSharp

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using this below code i get the name only first 4 character.But i need
Hi i using this mysql code to generate this data below: code: SELECT L.LEAVETYPE,
i am using this code below to dynamically capture the name of the button
Hi I'm using this code below to let a user draw their signature on
I'm using this code, and I get the stack trace that is listed below.
I tried to send an email using this class below, but no success, no
Please can anyone help me out with this problem? This code below works perfectly
i'm using this code below to drag an image across the screen. The one
I am using this below code to re-write URL : RewriteEngine on RewriteRule ^buynow/(.*)$
As of right now I'm using this code below to download files to get

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.