Save PDF as Editable

Posted by: mchandler2 on 20 March 2020, 12:36 pm EST

    • Post Options:
    • Link

    Posted 20 March 2020, 12:36 pm EST

    I have learned how to open a PDF template, fill it with field values, and save it as Read-only. This is the default.

    My next step is to save the template with my values, but when it is opened in Acrobat Reader, I want it to still be editable.

    How do I make the saved PDF editable?

  • Posted 23 March 2020, 12:54 am EST

    Hi,

    As we understand you want to modify field(s) in an existing AcroForm field and still allow the user to be able to edit the PDF.

    To do this, please refer following link [Heading Modify AcroForm fields] that should help you with the same: https://www.grapecity.com/documents-api-pdf/docs/online/Forms.html

    ~Regards,

  • Posted 23 March 2020, 1:19 am EST

    I appreciate your response. However, the link only provides examples of programmatically adding, modifying, and deleting fields in a PDF. When I save the PDF using GcPdfDocument.Save and open it in Acrobat Reader, all the fields are “flattened” and are no longer editable.

    What I need is an example of saving the PDF in such a way that it can be opened in Acrobat Reader and still be editable.

  • Posted 23 March 2020, 4:11 am EST

    Hi,

    Your original form uses a rather rare and specific ‘Perms’ feature in the document, as described in #12.8.6 of the PDF 2.0 spec. This entry allows to specify certain permissions on the document in addition to the ‘normal’ document permissions, in particular in your document those permissions prevent form filling if the original form has been modified (as is the case here).

    The interesting thing about those permissions is that they are not enforced by any encryption, and are ignored by all PDF viewers that I tried except the Acrobat Reader. They are even ignored by Acrobat Pro.

    Unfortunately, the current version of GcPdf does not allow to clear those permissions. We have investigated this and have added a method to clear them. This will be added in the next hotfix which should become available in a week or so. I will post an update here, till then you can use e.g. our GcPdfViewer for testing:

    https://www.grapecity.com/documents-api-pdf/demos/gc-pdf-viewer/viewer-edit-all/pdf-cs

    (Click the ‘open file’ icon in the top left.)

    I will post and update here when the version that allows clearing the permissions is available.

    Thanks,

    Dmitry.

  • Posted 23 March 2020, 5:50 am EST

    I am attaching three files. CodeThatCreatesGrapeCity.zip is the function to create a simple PDF to use as a fillable template. (All the fields are ReadOnly = False. It does not contain any rare or specific Permissions.) GrapeCity.zip is the created template. PopulatedGrapeCityPDF.zip is a PDF created by opening the template in code, filling the fields in code, and saving.

    If I understand you correctly, I should be able to edit (with your editor) both the unfilled template and the filled PDF. However, when I open either the unfilled template or the filled PDF file using the viewer in the link above, they are not editable.

    Please post a code example where you are successful at doing this.

  • Posted 23 March 2020, 6:01 am EST

    Hi,

    Sorry but I do not see any attachments in your message. Please post them, or you can email them to me: dmitry.yaitskov at grapecity.com

    Thanks.

  • Posted 23 March 2020, 7:51 am EST

    Hi Mary Ann,

    Attached is the complete project that creates the form, please run it on your system and let me know whether it produces an editable PDF.

    CreateForm_VB.zip

  • Posted 23 March 2020, 8:36 am EST

    Hi again,

    One more thing: in the 2 PDFs that you sent me, the ReadOnly flag on all fields is set to True. Simply loading your PDFs, setting f.ReadOnly = False and saving them produced normal editable PDFs. Here is the complete code that does that, just modify the file names accordingly:

    Imports System
    Imports System.IO
    Imports GrapeCity.Documents.Pdf
    Imports GrapeCity.Documents.Pdf.AcroForms
    
    Module Program
        Sub Main(args As String())
            Using fs = New FileStream("MyGrapeCityPDF.pdf", FileMode.Open, FileAccess.Read, FileShare.Read)
                Dim doc = New GcPdfDocument()
                doc.Load(fs)
                EnumFields(doc.AcroForm.Fields)
                doc.Save("MyGrapeCityPDF-editable.pdf")
            End Using
    
        End Sub
    
        Sub EnumFields(fields As FieldCollection)
            For Each f In fields
                Console.WriteLine($"name: {f.Name} readonly: {f.ReadOnly}")
                If f.ReadOnly Then
                    f.ReadOnly = False
                End If
                EnumFields(f.Children)
            Next
        End Sub
    End Module
    
    
  • Posted 27 March 2020, 4:34 am EST

    I’ll mark my last post as answer. Please let me know if you have more questions.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels