PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Jun 21, 2018 12:35 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Bug when flattening form
PostPosted: Fri Apr 27, 2018 3:08 pm 
Offline

Joined: Fri Apr 27, 2018 12:33 pm
Posts: 2
Hello,

I found a bug flattening a form. When I flatten a document, the fields that contain a "." are not flattened while other fields do.


Here is the original document:
Attachment:
form.jpg
form.jpg [ 65.52 KiB | Viewed 580 times ]


And this is the result:
Attachment:
formfilled.jpg
formfilled.jpg [ 59.19 KiB | Viewed 580 times ]


The url to the original file:
http://www.navarra.es/NR/rdonlyres/1773 ... eneral.pdf


The only thing I do is:
Code:
            // Load form pdf
            var document = PdfReader.Open("form.pdf");

            // Flatten the form
            document.Flatten();


This way the result is the same:
Code:
            // Load form pdf
            var document = PdfReader.Open("../../testFiles/form.pdf");

            // Flatten the form
            PdfAcroForm form = document.AcroForm;
            if (form != null)
            {
                PdfAcroField.PdfAcroFieldCollection fields = form.Fields;
                for (int i = 0; i < fields.Count(); i++)
                {
                    fields[i].ReadOnly = true;
                }
            }


I´m using the latest version of PdfSharp (1.50.4845-RC2a).

Perhaps I'm doing something wrong..

Thanks!

Iñigo


Attachments:
fillForm.zip [41.49 KiB]
Downloaded 38 times
Top
 Profile  
Reply with quote  
PostPosted: Sun Apr 29, 2018 4:10 pm 
Offline
User avatar

Joined: Wed Dec 09, 2009 8:59 am
Posts: 307
Hi!
Imus wrote:
Perhaps I'm doing something wrong.
If you think this is a bug then please use the IssueSubmissionTemplate.
viewtopic.php?f=2&t=832

The Flatten method is based on user feedback. It's not my area of expertise. There may be special cases that need special treatment.

_________________
Öhmesh Volta ("() => true")
PDFsharp Team Holiday Substitute


Top
 Profile  
Reply with quote  
PostPosted: Mon Apr 30, 2018 6:46 am 
Offline

Joined: Fri Apr 27, 2018 12:33 pm
Posts: 2
Hi!

() => true wrote:
If you think this is a bug then please use the IssueSubmissionTemplate.
Yes, the zip file attached is based on that template.

Thanks!


Top
 Profile  
Reply with quote  
PostPosted: Sun May 06, 2018 1:16 pm 
Offline

Joined: Tue Sep 30, 2014 12:29 pm
Posts: 19
Quote:
When I flatten a document, the fields that contain a "." are not flattened while other fields do.
The current implementation only sets fields on the outermost hierarchy-level to read-only, child-fields are not handled.
Beside that, i do not see what setting fields to read-only has to do with flattening, even when it's done correctly.
This process can be easily reverted by simply removing the read-only flag from the fields.
I have not found an official description about what "flattening" actually means, but this sentence comes close to what i consider as "flattening":
Quote:
Forms flattening is the process of removing this separate form data and adding it as text, images and shapes into the actual PDF data stream.
The PDF will still look the same but the user can no longer interact with the forms.
Source: https://blog.idrsolutions.com/2011/01/w ... lattening/

I am in the process of evaluating the current 1.5 release for our production environment.
We are currently using a custom 1.32 version, where we have made some enhancements especially for Acro-Forms.
I forked PdfSharp on GitHub and shifted over some changes we made for 1.32; that includes "real" Form-Flattening (meaning there are no fields anymore after flattening).
Especially Font-handling for AcroFields may need a big overhaul as i think, the current state handles only the most basic font-related issues.
(e.g. Fields rendered with embedded fonts using some special encoding are not handled correctly at all...)
The current status of this fork is "experimental", as i have not (yet) done extensive testing with it.

But please take a look, and report whether it works for you:
https://github.com/packdat/PDFsharp/tree/AcroForms


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group