내부 및 외부 필드 복사

CopyInnerField 메서드는 동일한 파일에서 동일한 좌표에 있는 필드를 복사할 수 있도록 합니다. 이 메서드는 복사할 필드 이름, 새 필드 이름 및 필드를 복사해야 하는 페이지 번호가 필요합니다. FormEditor 클래스에서 이 메서드를 제공합니다. 다음 코드 스니펫은 동일한 파일에서 동일한 위치에 필드를 복사하는 방법을 보여줍니다.

 // For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void CopyInnerField()
{
    // The path to the documents directory
    var dataDir = RunExamples.GetDataDir_AsposePdf();

    // Create an instance of FormEditor object
    using (var formEditor = new Aspose.Pdf.Facades.FormEditor())
    {
        // Open PDF document
        using (var document = new Aspose.Pdf.Document(dataDir + "Sample-Form-01.pdf"))
        {
            // Add page
            document.Pages.Add();

            // Bind PDF document
            formEditor.BindPdf(document);

            // Copy the field "Last Name" from the first page to "Last Name 2" on the second page
            formEditor.CopyInnerField("Last Name", "Last Name 2", 2);

            // Save PDF document
            formEditor.Save(dataDir + "Sample-Form-01-mod.pdf");
        }
    }
}

기존 PDF 파일에서 외부 필드 복사

CopyOuterField 메서드는 외부 PDF 파일에서 양식 필드를 복사한 다음 입력 PDF 파일의 동일한 위치와 지정된 페이지 번호에 추가할 수 있도록 합니다. 이 메서드는 필드를 복사해야 하는 PDF 파일, 필드 이름 및 필드를 복사해야 하는 페이지 번호가 필요합니다. 이 메서드는 FormEditor 클래스에서 제공됩니다. 다음 코드 스니펫은 외부 PDF 파일에서 필드를 복사하는 방법을 보여줍니다.

// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void CopyOuterField()
{
    // The path to the documents directory
    var dataDir = RunExamples.GetDataDir_AsposePdf();

    // Create an instance of FormEditor 
    using (var formEditor = new Aspose.Pdf.Facades.FormEditor())
    {
        // Create empty document
        using (var document = new Aspose.Pdf.Document())
        {
            // Add page
            document.Pages.Add();

            // Bind PDF document
            formEditor.BindPdf(document);

            // Copy the outer field "First Name" from the original document to the new document
            formEditor.CopyOuterField(dataDir + "Sample-Form-01.pdf", "First Name", 1);

            // Copy the outer field "Last Name" from the original document to the new document
            formEditor.CopyOuterField(dataDir + "Sample-Form-01.pdf", "Last Name", 1);

            // Save PDF document
            formEditor.Save(dataDir + "Sample-Form-02-mod.pdf");
        }
    }
}