0
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.StringReader;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.html.simpleparser.HTMLWorker;
import com.itextpdf.text.pdf.PdfWriter;
public class myclass {
    public static void main(String[] args) {
        String result = "<html><body><div>(i) the recognised association shall have the approval of the Forward  Markets  Commission established under the Forward  Contracts (Regulation) Act, 1952 (74 of 1952) in respect of trading in derivatives and shall function in accordance with the guidelines or conditions laid down by the Forward  Markets  Commission; </div>  <body> </html>";
        try {
            OutputStream file = new FileOutputStream(new File("E:\\Test.pdf"));
            Document document = new Document();
            PdfWriter.getInstance(document, file);
            document.open();
            @SuppressWarnings("deprecation")
            HTMLWorker htmlWorker = new HTMLWorker(document);
            htmlWorker.parse(new StringReader(result));
            document.close();
            file.flush();
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (DocumentException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }
}

これは、itext と Html ワーカーを使用して Html から Pdf に保存するための私のコードですが、Html ファイルを Pdf に変換できますが、Pdf の上に On static Image{Logo} を追加する必要があります。テキストが表示されるはずです助けてください私はこれを行うことができません..

4

1 に答える 1