Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editable PDF form fields are getting cached #3274

Closed
SureshkPerumal opened this issue Mar 7, 2023 · 9 comments
Closed

Editable PDF form fields are getting cached #3274

SureshkPerumal opened this issue Mar 7, 2023 · 9 comments
Assignees
Labels
bug Something isn't working tracked We are tracking this work internally.

Comments

@SureshkPerumal
Copy link

SureshkPerumal commented Mar 7, 2023

Description
Use case:
1.User opens editable pdf from webpage which is rendered in webview2 browser control.
2.Edit the field in PDF and close pdf window without saving it.
3.when user open same pdf document type for different account, its prepopulating the previous account data in pdf form fields.

When we edit pdf form fields and close window without saving, seems webview2 cache form field values in local and it pre populate when same document is opened again from the server.it causes issue as it populates data entered for different account.

We could see "PDF Restore Data" folder in below path which has the pdf data.
EBWebView\Default\PDF Restore Data

Tried same use case in edge browser,in edge it shows below Leave site alert message message when click leave it delete pdf restore date folder from edge browser cache path.but in webview2 control we are not getting leave site alert message.
AppData\Local\Microsoft\Edge\User Data\Default\PDF Restore Data

  • Let us know how to prevent pdf form field values getting cached locally.
  • Let us know how to show leave site message in webview2 control so that it will delete pdf restore folder

Version
SDK: 1.0.1462.37
Runtime: 110.0.1587.63
Framework: WPF,.NET framework 4.8
OS: wind10

AB#43744375

@SureshkPerumal SureshkPerumal added the bug Something isn't working label Mar 7, 2023
@novac42
Copy link
Contributor

novac42 commented Mar 8, 2023

Thanks for reaching out. I've assigned this to a dev that can help follow up on this.

@monica-ch
Copy link
Contributor

Thanks for the bug report! I have added the issue to our backlog. We'll investigate and update the thread soon.

Checkout this API ClearBrowsingDataAsync to clear the cache in a time range when pdf widow is closed.

@monica-ch monica-ch added the tracked We are tracking this work internally. label Mar 13, 2023
@SureshkPerumal
Copy link
Author

@monica-ch ,
We can't clear all the cache because other webview2 in our application will using cache folders. We have to clear only pdf cache fields and not others.
ClearBrowsingDataAsync method takes browserdatakinds Enum.

please let me know which Enum we should use for only clearing PDF cache fields.
https://learn.microsoft.com/en-us/dotnet/api/microsoft.web.webview2.core.corewebview2browsingdatakinds?view=webview2-dotnet-1.0.1587.40

Please let us know logic behind the creation/deletion of "PDF Restore Data" folder in cache path.

Thanks

@monica-ch
Copy link
Contributor

@SureshkPerumal ClearBrowsingDataAsync method currently doesn't just clear pdf cache. Until we find a solution to this, can you use windows API to delete "PDF Restore Data" folder when PDF window is closed or navigated away.

@Master-Ukulele
Copy link

Hello @SureshkPerumal,

Here's a workaround to prevent pdf form field values getting cached locally by a feature flag 'msPdfDataRecovery'. In your App, you can config this through AdditionalBrowserArguments or command line. This will prevent both editable pdf saves the cache to local, and retrieves a local cache, if exists, to editable pdf.

The leave site message dialog cannot be activated in WV2 currently, it has some conflicts with WV2. Additional words to your case, the dialog won't guarantee a cache be saved or not, it actually works as it says 'Changes you made may not be saved'. The cache may exist even confirmed to leave from dialog. So the feature flag 'msPdfDataRecovery' may help you better.

Thanks,

@SureshkPerumal
Copy link
Author

SureshkPerumal commented Mar 24, 2023

@Master-Ukulele/ @monica-ch ,
Do wee need to set any value to this flag to disable pdf data caching?

CoreWebView2Environment coreEnv = await CoreWebView2Environment.CreateAsync(userDataFolder: webView2CachePath,
browserExecutableFolder: null,options:new CoreWebView2EnvironmentOptions("--msPdfDataRecovery=false"));

Confirm above initialization and provide any example.

Please share equivalent flag details for "Enable support for XFA in PDF".

Pdf is not loading properly in webveiw2 and working in edge after we enabled above option in edge flag.We need to set the above flag in webview2.

edge://flags/#edge-pdf-viewer-xfa

image

Thanks

@Master-Ukulele
Copy link

Master-Ukulele commented Mar 28, 2023

In the CoreWebView2EnvironmentOptions constructor, you can pass the AdditionalBrowserArguments as
new CoreWebView2EnvironmentOptions("--disable-features=msPdfDataRecovery")
Please refer to the AdditionalBrowserArguments documentation link above, it provides examples.

The flag for XFA in PDF feature is 'msPdfXFA'. I'm not sure what you mean by "Pdf is not loading properly ... after enabled ...". If you set the flag correctly, if the WebView2 supports the feature, and if your App supports, it should work as expected.

However, please don't ask any further questions other than the topic of Pdf cached issue in this thread. It's just better to help others to find the answer when they have the similar issue. If you have other issues, feel free to report it in a new issue.

Thanks

@SureshkPerumal
Copy link
Author

Hi @Master-Ukulele,
It worked. Both xfa and pdf cache issue resolved after setting environment options.

coreEnv = await CoreWebView2Environment.CreateAsync(userDataFolder: webView2CachePath,
browserExecutableFolder: null, options: new CoreWebView2EnvironmentOptions("--disable-features=msPdfDataRecovery --enable-features=msPdfXFA"));

Thanks.

@Master-Ukulele
Copy link

Updates: the msPdfDataRecovery feature has been disabled as default recently in sdk 1.0.1777-prerelease. That means no additional setting is required in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working tracked We are tracking this work internally.
Projects
None yet
Development

No branches or pull requests

4 participants