如何删除由start / end Document方法添加的StaxEventItemWriter <root>标记?

时间:2018-03-05 12:54:28

标签: java xml spring xsd spring-batch

如何删除由开始/结束文档方法添加的StaxEventItemWriter标记?

我在生成XML文件时默认添加,所以请任何人告诉我如何删除默认的根标记。

 Ex-
    <?xml version='1.0' encoding='UTF-8'?>
    <root>
    <ressourcespleiade date="2015-10-03 06:38:00.000">
    ---
    ---
    </..>

1 个答案:

答案 0 :(得分:0)

我结束了这样的事情:

Imports iTextSharp.text
Imports iTextSharp.text.pdf
Imports System.IO

Public Sub createPdfFileWithAnEmptySignatureField()
     Dim strOutputFilePath As String = "C:\Temp\File_ready_for_signing.pdf"
    Dim strFieldName as String = "myEmptySignatureField"
    Dim document As Document = New Document
    Dim writer As PdfWriter
    writer = PdfWriter.GetInstance(document, New FileStream(strOutputFilePath, FileMode.Create))
    document.Open()
    document.Add(New Paragraph("The following is an empty signature field:"))
    Dim field As PdfFormField = PdfFormField.CreateSignature(writer)
    field.SetWidget(New Rectangle(50, 740, 120, 780), PdfAnnotation.HIGHLIGHT_OUTLINE)
    field.FieldName = strFieldName
    writer.AddAnnotation(field)
    document.Close()
End Sub
IMO,这不是很干净,但也不是很糟糕。这样你就可以依赖StaxEventItemWriter类的每个机制,但是不写任何根元素。