This repository has been archived by the owner on Mar 9, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 134
How i can Share PDF File #15
Comments
You can either share the download link as plain text (SetText), or download the PDF file to the device and then share it as a file (AddFile). P.S. Sharing the download link as plain text may not work as desired; e.g. if user decides to share on Facebook, it will be shared as a link rather than as an attached file. |
You Can Put C# Example Code. |
How do you plan to share the PDF? As a link or as a file? |
The PDF are in Node Js serve in Public folder i want to download and put it in piece joint send after that deleted |
using System.Collections;
using System.IO;
using UnityEngine;
using UnityEngine.Networking;
public void Share( string url )
{
StartCoroutine( DownloadAndShare( url ) );
}
private IEnumerator DownloadAndShare( string url )
{
// Credit: https://docs.unity3d.com/Manual/UnityWebRequest-CreatingDownloadHandlers.html
var uwr = new UnityWebRequest( url, UnityWebRequest.kHttpVerbGET );
string path = Path.Combine( Application.temporaryCachePath, "temp.pdf" );
uwr.downloadHandler = new DownloadHandlerFile( path );
yield return uwr.SendWebRequest();
if( uwr.isNetworkError || uwr.isHttpError )
Debug.LogError( uwr.error );
else
new NativeShare().AddFile( path ).Share();
// It may not be safe to delete the file immediately afterwards,
// maybe it is currently being shared? Instead, you can delete the file
// at that "path" later in your app's lifecycle or when your app starts
// File.Delete( path );
} |
Thank you very much #yasirkula you are awesome 👍 😃 |
ghost
mentioned this issue
Jul 10, 2019
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I need to now how i can share pdf. file i have files in node js server i have a direct link to them how i can do that
The text was updated successfully, but these errors were encountered: