Load a PDF from a remote URL in C#
To load a PDF document from a remote URL, use the LoadFromHttp method of the GdPicturePDF class.
LoadFromHttp takes a Uri object and returns a GdPictureStatus. You should always check the returned status before continuing.
To load a PDF document from a URL, use the following code:
using GdPicture14;using System;
using GdPicturePDF gdpicturePDF = new GdPicturePDF();
// Create a Uri object pointing to a PDF document.Uri pdfUri = new Uri("https://pspdfkit.com/downloads/pspdfkit-web-demo.pdf");
// Load the PDF document from URL.GdPictureStatus status = gdpicturePDF.LoadFromHttp(pdfUri);if (status != GdPictureStatus.OK){ Console.WriteLine($"LoadFromHttp failed: {status}"); return;}
// Save the loaded PDF document.status = gdpicturePDF.SaveToFile(@"C:\temp\output.pdf");if (status != GdPictureStatus.OK){ Console.WriteLine($"SaveToFile failed: {status}");}Imports GdPicture14
Using gdpicturePDF As New GdPicturePDF() ' Create a Uri object pointing to a PDF document. Dim pdfUri As New Uri("https://pspdfkit.com/downloads/pspdfkit-web-demo.pdf")
' Load the PDF document from URL. Dim status As GdPictureStatus = gdpicturePDF.LoadFromHttp(pdfUri) If status <> GdPictureStatus.OK Then Console.WriteLine($"LoadFromHttp failed: {status}") Return End If
' Save the loaded PDF document. status = gdpicturePDF.SaveToFile("C:\temp\output.pdf") If status <> GdPictureStatus.OK Then Console.WriteLine($"SaveToFile failed: {status}") End IfEnd Using