qq_29776255 2015-09-14 08:34 采纳率: 0%
浏览 1563

asterisk12 技术如何在终端掉线时取消自动踢人功能啊

使用asterisk12 如何在终端掉线时取消自动踢人功能啊?

  • 写回答

1条回答 默认 最新

  • hkm880914 2015-09-14 12:37
    关注

    public void exportPdf(String title, String[] headers,
    Collection dataset, OutputStream out, String pattern) {
    // 作为报表的PDF文件,一定要适合打印机的输出打印
    Rectangle rectPageSize = new Rectangle(PageSize.A4);// 定义A4页面大小
    // rectPageSize = rectPageSize.rotate();// 加上这句可以实现A4页面的横置
    Document document = new Document(rectPageSize, 50, 50, 50, 50);// 其余4个参数,设置了页面的4个边距
    try {
    // 将PDF文档写出到out所关联IO设备上的书写对象
    PdfWriter.getInstance(document, out);
    // 添加文档元数据信息
    document.addTitle(StrHelp.getChinese(title));
    document.addSubject("export information");
    document.addAuthor("leno");
    document.addCreator("leno");
    document.addKeywords("pdf itext");
    // 定义页头和页尾
    HeaderFooter header = new HeaderFooter(new PdfParagraph(title, 20,
    true), false);
    header.setAlignment(Element.ALIGN_CENTER);
    HeaderFooter footer = new HeaderFooter(new Phrase(
    "This is page "), new Phrase("."));
    footer.setAlignment(Element.ALIGN_CENTER);
    document.setHeader(header);
    document.setFooter(footer);
    // 打开PDF文档
    document.open();
    // 添加一张表格,使用Table或者PdfPTable
    // Table table = new Table(headers.length);
    // table.setWidth(16*headers.length);
    // //table.setWidths(new float[]{20,20,20,30});
    // table.setCellsFitPage(true);
    // table.setAutoFillEmptyCells(true);
    // table.setAlignment(Table.ALIGN_CENTER);
    // table.setBackgroundColor(Color.yellow);
    // table.setBorderColor(Color.green);
    PdfPTable table = new PdfPTable(headers.length);
    // table.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.setWidthPercentage(16 * headers.length);
    // 产生表格标题行
    for (int i = 0; i < headers.length; i++) {
    PdfPCell cell = new PdfPCell(new PdfParagraph(headers[i], 14,
    true));
    cell.setHorizontalAlignment(Cell.ALIGN_CENTER);
    cell.setVerticalAlignment(Cell.ALIGN_MIDDLE);
    cell.setBackgroundColor(Color.cyan);
    cell.setBorderColor(Color.green);
    table.addCell(cell);
    }
    // 遍历集合数据,产生数据行
    Iterator it = dataset.iterator();
    int index = 0;
    while (it.hasNext()) {
    index++;
    T t = (T) it.next();
    // 利用反射,根据javabean属性的先后顺序,动态调用getXxx()方法得到属性值
    Field[] fields = t.getClass().getDeclaredFields();
    for (short i = 0; i < fields.length; i++) {
    PdfPCell cell = null;
    Field field = fields[i];
    String fieldName = field.getName();
    String getMethodName = "get"
    + fieldName.substring(0, 1).toUpperCase()
    + fieldName.substring(1);
    try {
    Class tCls = t.getClass();
    Method getMethod = tCls.getMethod(getMethodName,
    new Class[] {});
    Object value = getMethod.invoke(t, new Object[] {});
    // 判断值的类型后进行强制类型转换
    String textValue = null;
    if (value instanceof Boolean) {
    boolean bValue = (Boolean) value;
    textValue = "男";
    if (!bValue) {
    textValue = "女";
    }
    } else if (value instanceof Date) {
    Date date = (Date) value;
    SimpleDateFormat sdf = new SimpleDateFormat(pattern);
    textValue = sdf.format(date);
    } else if (value instanceof byte[]) {
    byte[] bsValue = (byte[]) value;
    Image img = Image.getInstance(bsValue);
    cell = new PdfPCell(img);
    } else {
    textValue = value.toString();
    }
    // 如果不是图片数据,就当做文本处理
    if (textValue != null) {
    cell = new PdfPCell(new PdfParagraph(textValue));
    }
    cell.setHorizontalAlignment(Cell.ALIGN_CENTER);
    cell.setVerticalAlignment(Cell.ALIGN_MIDDLE);
    cell.setBorderColor(Color.green);
    table.addCell(cell);
    } catch (SecurityException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (NoSuchMethodException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (IllegalArgumentException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (IllegalAccessException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (InvocationTargetException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (MalformedURLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } finally {
    // 清理资源
    }
    }

    评论

报告相同问题?

悬赏问题

  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办