543276660 http://zhidao.baidu.com/new?
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/21 19:29:22
543276660 http://zhidao.baidu.com/new?
543276660 http://zhidao.baidu.com/new?
543276660 http://zhidao.baidu.com/new?
<=[\W\w])(\?|&)(?=[\W\w])*
确定是《夏娃的诱惑2娇妻》 第32分25秒镜头
(?<=[\W\w])(\?|&)(?=[\W\w])*
把PDF文件写入response流里面就可以了!
方法有很多,这里给个独立又简单的例子:
Java代码
1.package com.zhaipuhong.j2se.pdf;
2.
3.import java.io.IOException;
4.import java.util.Date;
5.
6.im...
全部展开
把PDF文件写入response流里面就可以了!
方法有很多,这里给个独立又简单的例子:
Java代码
1.package com.zhaipuhong.j2se.pdf;
2.
3.import java.io.IOException;
4.import java.util.Date;
5.
6.import javax.servlet.ServletException;
7.import javax.servlet.http.HttpServlet;
8.import javax.servlet.http.HttpServletRequest;
9.import javax.servlet.http.HttpServletResponse;
10.
11.import com.lowagie.text.Document;
12.import com.lowagie.text.DocumentException;
13.import com.lowagie.text.Paragraph;
14.import com.lowagie.text.pdf.PdfWriter;
15.import com.lowagie.text.pdf.BaseFont;
16.import com.lowagie.text.pdf.PdfPTable;
17.import com.lowagie.text.pdf.PdfPCell;
18.import java.awt.Color;
19.
20.public class PdfServlet extends HttpServlet {
21.
22. private static final long serialVersionUID = -6033026500372479591L;
23.
24. public void doGet (HttpServletRequest request, HttpServletResponse response)
25. throws IOException, ServletException {
26.
27. // step 1 建立文档对象
28. Document document = new Document();
29. try {
30. //设置文档相应类型
31. response.setContentType("application/pdf");
32. PdfWriter.getInstance(document, response.getOutputStream());
33.
34.
35. // step 3 打开文档
36. document.open();
37. //支持中文
38. BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
39. com.lowagie.text.Font FontChinese = new com.lowagie.text.Font(bfChinese, 12, com.lowagie.text.Font.NORMAL);
40. Paragraph pragraph=new Paragraph("你好", FontChinese);
41.
42.
43. // step 4 向文档中添加内容
44. document.add(pragraph);
45. document.add(new Paragraph(" Hello World !"));
46. document.add(new Paragraph("Date 时间"+new Date().toString()));
47. document.add(new Paragraph(new Date().toString()));
48. document.add(new Paragraph(new Date().toString()));
49.
50.
51.
52. PdfPTable table = new PdfPTable(3);
53. PdfPCell cell = new PdfPCell(new Paragraph("header with colspan 3"));
54. cell.setColspan(3);
55. table.addCell(cell);
56. table.addCell("1.1");
57. table.addCell("2.1");
58. table.addCell("3.1");
59. table.addCell("1.2");
60. table.addCell("2.2");
61. table.addCell("3.2");
62. cell = new PdfPCell(new Paragraph("cell test1"));
63. cell.setBorderColor(new Color(255, 0, 0));
64. table.addCell(cell);
65. cell = new PdfPCell(new Paragraph("cell test2"));
66. cell.setColspan(2);
67. cell.setBackgroundColor(new Color(0xC0, 0xC0, 0xC0));
68. table.addCell(cell);
69. document.add(table);
70.
71. }catch(DocumentException de) {
72. de.printStackTrace();
73. System.err.println("document: " + de.getMessage());
74. }
75.
76. // step 5: 关闭文档对象
77. document.close();
78. }
79.
80. //支持中文
81. public Paragraph getChineseString(String chineseString){
82. Paragraph pragraph=null;
83. BaseFont bfChinese = null;
84. try {
85. bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H",
86. BaseFont.NOT_EMBEDDED);
87. com.lowagie.text.Font FontChinese = new com.lowagie.text.Font(bfChinese,
88. 12, com.lowagie.text.Font.NORMAL);
89. pragraph = new Paragraph(chineseString, FontChinese);
90. }
91. catch (Exception ex) {
92. ex.printStackTrace();
93. }
94. return pragraph;
95. }
96.}
收起