Load an image for conversion from a remote URL in C#

Image

To load and convert an image from a remote URL, use the LoadFromHttp method from the GdPictureDocumentConverter class. This method requires the following parameters:

  • HttpUri — A Uri variable pointing to an image.
  • DocumentFormat — The file format represented as a member of the DocumentFormat enumeration.

To load and convert an image from a remote URL, use the following code:

using GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter();
// Create a `Uri` variable.
Uri fileUri = new Uri("https://pspdfkit.com/downloads/load-a-file/source.jpg");
// Specify the file format.
GdPicture14.DocumentFormat format = GdPicture14.DocumentFormat.DocumentFormatJP2;
// Load an image from a URL.
gdpictureDocumentConverter.LoadFromHttp(fileUri, format);
// Save the PDF document to file.
gdpictureDocumentConverter.SaveAsPDF(@"C:\temp\output.pdf");