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 worker 从 Html 保存到 Pdf 我能够将 Html 文件转换为 Pdf 但我需要在 Pdf 中添加 On static Image{Logo} 在 Pdf 的顶部意味着如果第一个 Logo 图像那么文本应该出现请帮助我我无法做到这一点..

4

1 回答 1

0

我认为这是用于所有 pdf 操作的好习惯itext,我认为html worker这不足以满足您的需要。有关图像 pdf 相关教程,请参阅

于 2013-08-09T10:26:17.773 回答