GeneratePDF.java 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. *
  3. */
  4. package test;
  5. import java.io.File;
  6. import java.io.FileOutputStream;
  7. import java.util.Date;
  8. //import com.itextpdf.text.Document;
  9. //import com.itextpdf.text.Paragraph;
  10. //import com.itextpdf.text.pdf.PdfWriter;
  11. /**
  12. * @author xzx
  13. *
  14. * 2019年5月5日
  15. *
  16. */
  17. public class GeneratePDF {
  18. /* private static String USER_PASS = "123";
  19. private static String OWNER_PASS = "321";
  20. public static void main(String[] args) {
  21. try {
  22. FileOutputStream file = new FileOutputStream(new File("D:\\Test1.pdf"));
  23. Document document = new Document();
  24. PdfWriter writer = PdfWriter.getInstance(document, file);
  25. // writer.setEncryption(USER_PASS.getBytes(), OWNER_PASS.getBytes(),
  26. // PdfWriter.ALLOW_PRINTING, PdfWriter.ENCRYPTION_AES_128);
  27. document.open();
  28. document.add(new Paragraph("Hello World, iText2222222222"));
  29. document.add(new Paragraph(new Date().toString()));
  30. document.close();
  31. file.close();
  32. } catch (Exception e) {
  33. e.printStackTrace();
  34. }
  35. }*/
  36. }