IWithPdfCreation.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright (c) 2024 Vuplex Inc. All rights reserved.
  2. //
  3. // Licensed under the Vuplex Commercial Software Library License, you may
  4. // not use this file except in compliance with the License. You may obtain
  5. // a copy of the License at
  6. //
  7. // https://vuplex.com/commercial-library-license
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. using System.Threading.Tasks;
  15. namespace Vuplex.WebView {
  16. /// <summary>
  17. /// An interface implemented by a webview if it supports creating a PDF from a web page.
  18. /// Created PDFs are saved to Application.temporaryCachePath, but you can move them to a different
  19. /// location after they are created. If you wish to format the PDF differently on Windows and macOS,
  20. /// you can achieve that by using StandaloneWebView.CreatePdf() instead.
  21. /// </remarks>
  22. /// <remarks>
  23. /// On iOS, PDF creation is only supported on iOS 14 and newer.
  24. /// </remarks>
  25. /// Important notes:
  26. /// <list type="bullet">
  27. /// <item>On iOS, PDF creation is only supported on iOS 14 and newer.</item>
  28. /// <item>On iOS and visionOS, generated PDFs are not paginated (i.e. the PDF is one long page) due to a limitation of WKWebView's PDF functionality.</item>
  29. /// </list>
  30. /// </remarks>
  31. /// <example>
  32. /// <code>
  33. /// await webViewPrefab.WaitUntilInitialized();
  34. /// var webViewWithPdfCreation = webViewPrefab.WebView as IWithPdfCreation;
  35. /// if (webViewWithPdfCreation == null) {
  36. /// Debug.Log("This 3D WebView plugin doesn't yet support IWithPdfCreation: " + webViewPrefab.WebView.PluginType);
  37. /// return;
  38. /// }
  39. /// var pdfFilePath = await webViewWithPdfCreation.CreatePdf();
  40. /// // Now that the PDF has been created, do something with it.
  41. /// // For example, you can move it to a different location.
  42. /// File.Move(pdfFilePath, someOtherLocation);
  43. /// </code>
  44. /// </example>
  45. public interface IWithPdfCreation {
  46. /// <summary>
  47. /// Creates a PDF from the current web page and returns the full file path of the created PDF.
  48. /// PDFs are saved to Application.temporaryCachePath, but you can move them to a different
  49. /// location after they are created.
  50. /// </summary>
  51. Task<string> CreatePdf();
  52. }
  53. }