In Visual Studio 2015 (C #), download a single PDF file.
I would like to make a pdf file divided by bookmarks. (use itextsharp)
A form (text box/radio button) exists in the PDF.

Error message

Open PDF after split output
⇒Select the text box and select the radio button and save
⇒ The radio button disappears when the PDF is opened again.
(The text box remains normal with the entered value.)

The radio button disappears from the PDF once saved.
I tried many things in programming, but I couldn't solve it, so I posted it here.

Applicable source code
// Open the reference PDF file
            rd = new PdfReader (txtInput.Text);
            Document oDocument = new Document (rd.GetPageSizeWithRotation (1));
            PdfCopy oPdfcopy = new PdfCopy (oDocument, new FileStream (txtOutput.Text + "\\ test.pdf", FileMode.Create));
            //oPdfcopy.SetMergeFields ();
            oDocument.Open ();
            for (int p = iSectionStart [6];p<= iSectionEnd [6];p ++)
                PdfImportedPage oPdfImportedPage = oPdfcopy.GetImportedPage (rd, p);
                oPdfcopy.AddPage (oPdfImportedPage);

            // PRAcroForm opracroform = rd.AcroForm;
            // if (opracroform! = null)
            // {
            // oPdfcopy.CopyDocumentFields (rd.);
            oPdfcopy.Close ();
            oDocument.Close ();
            rd.Close ();

Change the output page and save destination, etc.

Supplemental information (FW/tool version etc.)

Visual Studio2015 (C #)
itextsharp (version:

  • Answer # 1

    Instead of using PdfCopy, use PdfCopyFields,
    At the time of output, read the original pdf
    It was solved by specifying pages (SelectPages).

    Enter the code below.

    oPdfcopy = new PdfCopyFields (new FileStream (txtOutput.Text + "\\" + "test.pdf", FileMode.Create));
    rd = new PdfReader (txtInput.Text);
    rd.SelectPages ("2-4");// ★ select the relevant page part
    oPdfcopy.AddDocument (rd);// PDF output
    oPdfcopy.Close ();// Save PDF