import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import com.itextpdf.text.Document;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfWriter;
public class GeneratePDF {
public static void main(String[] args) {
try {
String k = "<html><body> This is my Project </body></html>";
OutputStream file = new FileOutputStream(new File("E:\\Test.pdf"));
Document document = new Document();
PdfWriter.getInstance(document, file);
document.open();
document.add(new Paragraph(k));
document.close();
file.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
Bu, HTML'yi PDF'ye dönüştürme kodum. Ben sadece dönüştürmek için mümkün ancak PDF dosyası içinde tüm HTML olarak kaydeder. <html><body> This is my Project </body></html>
, sadece This is my Project
'u kaydettirirken PDF'ye kaydedilir.HTML'yi PDF'ye dönüştürmek için nasıl kullanılır iText
bu deneyin http://stackoverflow.com/questions/4712641/java-how-to-convert-a-html -de-pdf-olmadan-formatlama-formatlama – pratZ
Ben java dönüştürmek gerekir –
[Apache açık ofis API] (http://wiki.openoffice.org/wiki/API/Tutorials/PDF_export#How_to_use_it_from_Java) –