logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Post a reply
From:
Message:

Maximum number of characters in each post is: 32767
Bold Italic Underline   Highlight Quote Choose Language for Syntax Highlighting Insert Image Insert an existing Attachment or upload a new File... Create Link   Unordered List Ordered List   Left Justify Center Justify Right Justify   Outdent Indent   More BBCode Tags
Font Color Font Size
Security Image:
Enter The Letters From The Security Image:
  Preview Post Cancel

Last 10 Posts (In reverse order)
matt.smokeball Posted: Wednesday, June 13, 2018 3:37:04 PM(UTC)
 
Apologies, I forgot to update this post! The issue was that I was not using the NoIncremental flag, and also not calling ForceToKillFocus() before saving. Thanks for you support with this!
Paul Rayman Posted: Tuesday, May 1, 2018 9:34:20 PM(UTC)
 
Looks like I did not understand the problem.
Everything looks fine.


if you are using PdfDocument.Load instead of PdfViewer.LoadDocument then you need to do that in the following manner
Code:

public void LoadDocument()
{
    var f = new PdfForms();
    var doc = PdfDocument.Load(@"d:\32\Bank of Melbourne Discharge Authority.pdf", f);
    pdfViewer1.Document = doc;
}

public void SaveDocument()
{
    pdfViewer1.Document.FormFill.ForceToKillFocus();
    pdfViewer1.Document.Save(@"d:\32\Bank of Melbourne Discharge Authority - saved.pdf", SaveFlags.NoIncremental);
}
matt.smokeball Posted: Tuesday, May 1, 2018 9:17:02 PM(UTC)
 
We are using the WPF viewer. Thanks.
Paul Rayman Posted: Tuesday, May 1, 2018 9:16:07 PM(UTC)
 
Are you using WinForms or WPF PDFViewer?
matt.smokeball Posted: Tuesday, May 1, 2018 8:59:25 PM(UTC)
 
Yeah sure. The PDF document I'm testing with is attached. We're using the latest version. Thanks!

Bank of Melbourne Discharge Authority.pdf (110kb) downloaded 25 time(s).
Paul Rayman Posted: Tuesday, May 1, 2018 8:20:05 PM(UTC)
 
Are you using latest version?
https://forum.patagames....released-on-Apr-16--2018
Also please make sure you are using NoIncremental flag.
If so, could you please provide the document, where the forms cannot be saved?
matt.smokeball Posted: Tuesday, May 1, 2018 8:10:12 PM(UTC)
 
Hi Paul

Thanks for the quick reply! I understand about the save, thanks for clearing that up.

In regards to the mapping/field values, what I need to be able to do is save the value a user enters into the document, with the document. So a text field for example, should save the entered text when the document is saved to the file path.

Currently, it's not doing that when I call the save methods.

I have the code below, which will save a "mapping" to the field. The mapping is just a string value that is used as a way to identify what value to place into the field, from our own databases (essentially trying to automate the form fill).

When calling save, this mapping value is saved into the document ok. However the actual field value is not (i.e: Field.Value = "some string").

Hope this helps to clarify a little. Thanks again!

Code:

 public static class PdfFieldExtensions
    {
        public static void SetMapping(this PdfField field, string mapping)
        {
            var tm = PdfTypeString.Create();
            tm.AnsiString = mapping;

            if (field.Dictionary.ContainsKey("TM"))
            {
                field.Dictionary["TM"] = tm;
            }
            else
            {
                field.Dictionary.Add("TM", tm);
            }
        }
    }
Paul Rayman Posted: Tuesday, May 1, 2018 7:27:43 PM(UTC)
 
Hi,

Quote:

I'm using the viewer to display the documents. however, when I call document.Save(), it doesn't seem to be saving the file at all. I have to call document.Save(new temp file path) to get it to work.


Pdfium does not load the entire contents of the document into memory, but reads the necessary portion of data from the file as needed. For this reason, a write lock is set on the file. Thus, there are only the methods to saving a copy of the documents, but not saving the document to the same file.
All overloads of the Save method saves the copies of the document in a different location.
https://pdfium.patagames...92-4c9c-3fb58a2dd2e6.htm

Overloading without specifying where to store the copy can be used to save the document in any different from the standard way. Calling the Save function without specifying the path, the engine fires the WriteBlock event. You can hadle it and implement your own save to whatever destination you want (to the database for example).

Quote:

Also, it never saves the field values into the document. The mappings save in the document, but not the values.

Could you please clarify that you mean under "mappings" and "values"
Also please do not forget to call ForceToKillFocus before saving
https://pdfium.patagames...40-cf1b-502be7b41983.htm
My assumption is that the problem might be here.

matt.smokeball Posted: Tuesday, May 1, 2018 6:28:16 PM(UTC)
 
Hi

I'm currently using the Trial version of the software. Everything so far has been very good.

Just having some small issues. We need to save the pdf documents, including any field mappings/values.

I'm using the viewer to display the documents. however, when I call document.Save(), it doesn't seem to be saving the file at all. I have to call document.Save(new temp file path) to get it to work.

Also, it never saves the field values into the document. The mappings save in the document, but not the values.

Hoping this is possible and I'm not doing it correctly?