display pdf without downloading locally

Answered
0
0

Hi,

I have that function:

public static void displayPDF(MemoryStream ms, Page returnPage = null, string title = “”)
{
if (isMobile())//on mobile that is the only working way until now…
{
Application.DownloadAndOpen(“_blank”, ms, title);
return;
}
var f = new Page();
if (returnPage != null) AddReturnFloatingButton(f, returnPage); //display a button to get back…
Application.Title = title;
Wisej.Web.PdfViewer v = new PdfViewer();
v.Dock = DockStyle.Fill;
v.PdfStream = ms;
v.FileName = title;
v.ViewerType = PdfViewerType.Auto;
f.Controls.Add(v);
f.Show();
}

As stated in comments, that works perfect on PC, but on Android PdfViewer seems unable to display directly from stream or file. It shows an “Open” button than save it locally.

Is it any way to display a pdf on Android without downloading it locally?

 

Attachment
  • You must to post comments
Best Answer
0
0

It’s not a Wisej.NET issue- it’s an Android issue.

Try changing the PDF viewer to Mozilla instead of using the default PDF Viewer.

See also https://wisej.com/support/question/pdfviewer-problems

  • Adrian Zagar
    Sorry, my bad, I didn’t pay attention to that post (made by myself). It’s working that way. Thank you!
  • You must to post comments
0
0

Just to add details: using PdfSource instead of PdfStream is even worse, just a “cannot load plugin” is displayed in the center of PdfViewer.

 

public static void DisplayPDF(byte[] pdfBytes, Page returnPage = null, string title = “”)
{
string nf=GenerateName(10) + “.pdf”;
string url = Application.Url + $”temp/{nf}”;
string path = Path.Combine(Application.StartupPath, “temp”, nf);
if (!Directory.Exists(Path.Combine(Application.StartupPath, “temp”))) Directory.CreateDirectory(Path.Combine(Application.StartupPath, “temp”));
File.WriteAllBytes(path, pdfBytes);
var f = new Page();
if (returnPage != null) AddReturnFloatingButton(f, returnPage);
Application.Title = title;
Wisej.Web.PdfViewer v = new PdfViewer();
v.Dock = DockStyle.Fill;
v.PdfSource = url;
v.FileName = title;
v.ViewerType = PdfViewerType.Auto;
f.Controls.Add(v);
f.Show();
}

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.