2011-04-12 3 views
2

워크 플로는 다음과 같이이다 :iTextSharp - XFA 채우기 날짜/시간 필드

  1. 우리가 템플릿 양식을 다운로드 정적 될 것입니다 미리 작성된 값은 XML 템플릿을
  2. 는 XML이와 구문 분석을 내 보냅니다. NET 형태의 응용 프로그램은 동적 값은 그러나 어떤 이유로, 날짜/시간 필드,
  3. 결과 XML 다시 PDF 템플릿

모든 잘 iTextSharp에 MergeXfaData 방법을 사용하여 간다로 가져와야 추가 (텍스트 필드와 체크 박스는 괜찮습니다.) 채워지지 않습니다. 이유를 알아낼 수 없습니다. 포럼을 통해 검색하면 XFA가 텍스트 필드에서만 작동한다고 말하는 사람을 발견했습니다. 왜 이것과 어떻게 해결할 수 있습니까?

다음 단계로 첨부 파일을 PDF 양식에 첨부해야합니다. 첨부 파일도 PDF이지만 iTextSharp는 첨부하지 않습니다. 많은 포럼을 검색했지만 언급 된 방법 중 아무 것도 나를 위해 작동하지 않습니다.

난 그냥 날짜/시간 필드를 시도하고 완벽하게 작동, 답

답변

3

@Yuri 주셔서 감사합니다. Live Cycle에서 1 개의 텍스트와 1 개의 날짜/시간 및 Submit 및 Print라는 두 개의 버튼으로 간단한 PDF를 만듭니다. 샘플 PDF는 here입니다 :

나는 양식을 작성하여 XML이있어 :

<?xml version="1.0" encoding="UTF-8"?> 
<topmostSubform> 
    <Text1>Chris</Text1> 
    <DateTimeField1>2012-04-12</DateTimeField1> 
</topmostSubform> 

나는 PDF로 수입 및 날짜/시간 필드가 작성되었다 Acrobat의 PDF를 볼 때. 다음 코드와 함께 iTextSharp 5.0.5.0을 사용하고 있습니다.

Option Explicit On 
Option Strict On 

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

Public Class Form1 

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 
     Dim PDF_Input_File As String = Path.Combine(My.Computer.FileSystem.SpecialDirectories.Desktop, "Input.pdf") 
     Dim PDF_Output_File As String = Path.Combine(My.Computer.FileSystem.SpecialDirectories.Desktop, "Export.pdf") 

     ''//Create our reader 
     Dim reader As New PdfReader(PDF_Input_File) 
     ''//Create our file stream to output to 
     Using FS As New System.IO.FileStream(PDF_Output_File, FileMode.Create, FileAccess.Write, FileShare.Read) 
      ''//Create the stamper 
      Dim stamper As New PdfStamper(reader, FS) 

      ''//Just loading the XML raw instead of reading from disk, less files to attach to the post 
      Dim Bytes = System.Text.Encoding.UTF8.GetBytes("<?xml version=""1.0"" encoding=""UTF-8""?><topmostSubform><Text1>Chris</Text1><DateTimeField1>2012-04-12</DateTimeField1></topmostSubform>") 
      Using MS As New MemoryStream(Bytes) 
       ''//Fill out the form 
       stamper.AcroFields.Xfa.FillXfaForm(MS) 
      End Using 

      stamper.Close() 
     End Using 

     reader.Close() 


     Me.Close() 
    End Sub 
End Class 
+0

해결되었습니다. 나쁜 방법을 사용하고있었습니다. 첨부 파일에 대해서도 마찬가지입니다. – Yuri

+0

전자 서명 (알려진 이름의 기존 필드)을 추가하고 양식을 자동으로 제출하는 방법을 알려주십시오. – Yuri

+0

또한 양식이 성공적으로 제출되었는지 여부를 알려주는 방법이 있습니까? – Yuri

관련 문제