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 5949645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:16:46+00:00 2026-05-22T17:16:46+00:00

I have a simple HTML page, iText is able to produce a PDF from

  • 0

I have a simple HTML page, iText is able to produce a PDF from it. It’s fine but the checkbox is ignored. What can I do about it ?

import java.io.FileOutputStream;
import java.io.StringReader;

import com.itextpdf.text.Document;
import com.itextpdf.text.PageSize;
import com.itextpdf.text.html.simpleparser.HTMLWorker;
import com.itextpdf.text.pdf.PdfWriter;

public class HtmlToPDF {

  public static void main(String ... args ) {
    try {
      Document document = new Document(PageSize.LETTER);
      PdfWriter pdfWriter = PdfWriter.getInstance(document, new FileOutputStream("c://temp//testpdf.pdf"));
      document.open();
      String str = "<HTML><HEAD></HEAD><BODY><H1>Testing</H1><FORM>" + 
                   "check : <INPUT TYPE='checkbox' CHECKED/><br/>" +
                   "</FORM></BODY></HTML>";

      htmlWorker.parse(new StringReader(str));
      document.close();
      System.out.println("Done.");
      } 
    catch (Exception e) {
      e.printStackTrace();
    }
  }
}

I got it working with YAHP ( http://www.allcolor.org/YaHPConverter/ ).

import java.io.File;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


// http://www.allcolor.org/YaHPConverter/
import org.allcolor.yahp.converter.CYaHPConverter;
import org.allcolor.yahp.converter.IHtmlToPdfTransformer;

public class HtmlToPdf_yahp {

    public  static void main(String ... args ) throws Exception {
        htmlToPdfFile();
    }

    public static void htmlToPdfFile() throws Exception {
            CYaHPConverter converter = new CYaHPConverter();
            File fout = new File("c:/temp/x.pdf");
            FileOutputStream out = new FileOutputStream(fout);
            Map properties = new HashMap();
            List headerFooterList = new ArrayList();

            String str = "<HTML><HEAD></HEAD><BODY><H1>Testing</H1><FORM>" +
                         "check : <INPUT TYPE='checkbox' checked=checked/><br/>"   +
                         "</FORM></BODY></HTML>"; 

            properties.put(IHtmlToPdfTransformer.PDF_RENDERER_CLASS,
                    IHtmlToPdfTransformer.FLYINGSAUCER_PDF_RENDERER);
            //properties.put(IHtmlToPdfTransformer.FOP_TTF_FONT_PATH, fontPath);
            converter.convertToPdf(str,
                IHtmlToPdfTransformer.A4P, headerFooterList, "file://c:/temp/", out,
                properties);
            out.flush();
            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-22T17:16:47+00:00Added an answer on May 22, 2026 at 5:16 pm

    creating pdfs with iText from html is a bit troubled.
    i advise to use the flying saucer library for this.
    it is also using iText in the background.

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

Sidebar

Related Questions

I have simple html page and need to post data (title/text) from that page
I have a simple HTML page on which I want to be able to
I have this very simple html page I ported from seam to playframework....the enter
I have a simple html page with a div. I am using jQuery to
In a simple html page I have: <SCRIPT> function Clicker(number){ if (number == 1)
I have a simple html form. On php page. A simple list is placed
So I have simple video tag on HTML 5 page playing OGG video. I
I have a simple HTML Table (10 columns x 500 rows). When the page
I have this html page which is very simple, it contains a text box
I have an HTML page with a simple form. When the user clicks submit,

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.