PDFViewerDefaultActionHandler.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. http://www.cgsoso.com/forum-211-1.html
  3. CG搜搜 Unity3d 每日Unity3d插件免费更新 更有VIP资源!
  4. CGSOSO 主打游戏开发,影视设计等CG资源素材。
  5. 插件如若商用,请务必官网购买!
  6. daily assets update for try.
  7. U should buy the asset from home store if u use it in your project!
  8. */
  9. using UnityEngine;
  10. namespace Paroxe.PdfRenderer.Internal.Viewer
  11. {
  12. class PDFViewerDefaultActionHandler : IPDFDeviceActionHandler
  13. {
  14. public void HandleGotoAction(IPDFDevice device, int pageIndex)
  15. {
  16. device.GoToPage(pageIndex);
  17. }
  18. public void HandleLaunchAction(IPDFDevice device, string filePath)
  19. {
  20. #if !UNITY_WEBGL
  21. if (filePath.Trim().Substring(filePath.Length - 4).ToLower().Contains("pdf"))
  22. {
  23. device.LoadDocumentWithFile(filePath, "", 0);
  24. }
  25. #endif
  26. }
  27. public string HandleRemoteGotoActionPasswordResolving(IPDFDevice device, string resolvedFilePath)
  28. {
  29. return "";
  30. }
  31. public string HandleRemoteGotoActionPathResolving(IPDFDevice device, string filePath)
  32. {
  33. return filePath;
  34. }
  35. public void HandleRemoteGotoActionResolved(IPDFDevice device, PDFDocument document, int pageIndex)
  36. {
  37. #if !UNITY_WEBGL
  38. device.LoadDocument(document, "", pageIndex);
  39. #endif
  40. }
  41. public void HandleRemoteGotoActionUnresolved(IPDFDevice device, string resolvedFilePath)
  42. {
  43. // ...
  44. }
  45. public void HandleUnsuportedAction(IPDFDevice device)
  46. {
  47. // ...
  48. }
  49. public void HandleUriAction(IPDFDevice device, string uri)
  50. {
  51. if (uri.Trim().Substring(uri.Length - 4).ToLower().Contains("pdf"))
  52. {
  53. #if !UNITY_WEBGL
  54. device.LoadDocumentFromWeb(uri, "", 0);
  55. #endif
  56. }
  57. else if (device.AllowOpenURL)
  58. {
  59. if (uri.Trim().ToLowerInvariant().StartsWith("http:")
  60. || uri.Trim().ToLowerInvariant().StartsWith("https:")
  61. || uri.Trim().ToLowerInvariant().StartsWith("ftp:"))
  62. {
  63. Application.OpenURL(uri);
  64. }
  65. }
  66. }
  67. }
  68. }