pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pp...@free.fr
Subject A xfa Pdf file can not be saved as.. by 'Save as..' from Adobe Acrobat Reader.
Date Fri, 05 May 2017 12:32:32 GMT
Hi everyone,
Using the pdfbox-1.8.13.dll and c#, i fill some forms of a xfa pdf file.
It works, a filled xfa pdf file is saved from my c# codes.
But when I use the 'Save as ...' for the filled xfa pdf file unders Adobe Acrobat Reader.
The message "Adobe Acrobat Reader can just only save  an empty copy of this document. Print
the modified document to keep a copy ..., blabla.." is displayed.
Does anyone have an idea to resolve that.
Thanks in advance.

My codes to fill and save a xfa pdf file :
using (PDDocument doc = PDDocument.load(nomComplet))
                PDDocumentCatalog pdCatalog = doc.getDocumentCatalog();
                PDAcroForm pdAcroForm = pdCatalog.getAcroForm();

                PDXFA xfa = pdAcroForm.getXFA();
                if (xfa != null)
                        // Remplir les valeurs dans la copie
                        COSBase cos = xfa.getCOSObject();
                        org.w3c.dom.Document w3c_xmldoc = xfa.getDocument();
                        // lire les noeuds contenants les champs PDF 
                        List<Node> nodes = ArpXfaPDFieldHelper.getElementsChampsPdfs(w3c_xmldoc,
_mainSubformname, true);
                        if (nodes.IsNullOrEmpty() == false)
                                foreach (var g in dicosChamps.GroupBy(o => o.Key.NomChampPdf))
                                        #region// Remplir d'un champs PDF Xfa à partir d'un
noeud org.w3c.dom.Node
                                        // .....
                                #region// enregistrer le document pdf rempli
                                String nomFichier = Path.GetFileName(nomComplet);
                                String extension = Path.GetExtension(nomComplet);
                                fichierRempli = nomComplet.Replace(nomFichier, "") + nomFichier.Replace(extension,
"") + "_rempli" + extension;
                                        COSStream cosout = new COSStream(new RandomAccessBuffer());
                                                .transform(new DOMSource(w3c_xmldoc), new
                                        pdAcroForm.setXFA(new PDXFA(cosout));

                                        // Suppression des permissions afin de pouvoir toujours
modifier le formulaire PDF une fois rempli.
                                        COSDictionary dico = pdCatalog.getCOSDictionary();
                                        if (dico.containsKey("Perms"))
                                                COSDictionary permission = dico.getDictionaryObject("Perms")
as COSDictionary;
                                                Boolean bUr3 = permission.containsKey("UR3");
                                                if (bUr3)
        catch (Exception ex)
                throw new MetierException(ex.Message);

To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org

View raw message