Load a PDF for Conversion from a Remote URL in C#

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

  • HttpUri — A Uri variable pointing to a PDF document.

  • DocumentFormat — The file format represented as a member of the DocumentFormat enumeration.

To load and convert a PDF document 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.pdf");
// Specify the file format.
GdPicture14.DocumentFormat format = GdPicture14.DocumentFormat.DocumentFormatPDF;
// Load a PDF document from a URL.
gdpictureDocumentConverter.LoadFromHttp(fileUri, format);
// Save the PDF document to file.
gdpictureDocumentConverter.SaveAsPDF(@"C:\temp\output.pdf");
Using gdpictureDocumentConverter As GdPictureDocumentConverter = New GdPictureDocumentConverter()
    ' Create a `Uri` variable.
    Dim fileUri As Uri = New Uri("https://pspdfkit.com/downloads/load-a-file/source.pdf")
    ' Specify the file format.
    Dim format As GdPicture14.DocumentFormat = GdPicture14.DocumentFormat.DocumentFormatPDF
    ' Load a PDF document from a URL.
    gdpictureDocumentConverter.LoadFromHttp(fileUri, format)
    ' Save the PDF document to file.
    gdpictureDocumentConverter.SaveAsPDF("C:\temp\output.pdf")
End Using

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

  • HttpUri — A Uri variable pointing to a Word document.

  • DocumentFormat — The file format represented as a member of the DocumentFormat enumeration.

To load and convert a Word document 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.docx");
// Specify the file format.
GdPicture14.DocumentFormat format = GdPicture14.DocumentFormat.DocumentFormatDOCX;
// Load a Word document from a URL.
gdpictureDocumentConverter.LoadFromHttp(fileUri, format);
// Save the PDF document to file.
gdpictureDocumentConverter.SaveAsPDF(@"C:\temp\output.pdf");
Using gdpictureDocumentConverter As GdPictureDocumentConverter = New GdPictureDocumentConverter()
    ' Create a `Uri` variable.
    Dim fileUri As Uri = New Uri("https://pspdfkit.com/downloads/load-a-file/source.docx")
    ' Specify the file format.
    Dim format As GdPicture14.DocumentFormat = GdPicture14.DocumentFormat.DocumentFormatDOCX
    ' Load a Word document from a URL.
    gdpictureDocumentConverter.LoadFromHttp(fileUri, format)
    ' Save the PDF document to file.
    gdpictureDocumentConverter.SaveAsPDF("C:\temp\output.pdf")
End Using

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");
Using gdpictureDocumentConverter As GdPictureDocumentConverter = New GdPictureDocumentConverter()
    ' Create a `Uri` variable.
    Dim fileUri As Uri = New Uri("https://pspdfkit.com/downloads/load-a-file/source.jpg")
    ' Specify the file format.
    Dim format As GdPicture14.DocumentFormat = 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")
End Using

To load and convert a bitmap 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 a bitmap image.

  • DocumentFormat — The file format represented as a member of the DocumentFormat enumeration.

To load and convert a bitmap 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.bmp");
// Specify the file format.
GdPicture14.DocumentFormat format = GdPicture14.DocumentFormat.DocumentFormatBMP;
// Load a bitmap image from a URL.
gdpictureDocumentConverter.LoadFromHttp(fileUri, format);
// Save the PDF document to file.
gdpictureDocumentConverter.SaveAsPDF(@"C:\temp\output.pdf");
Using gdpictureDocumentConverter As GdPictureDocumentConverter = New GdPictureDocumentConverter()
    ' Create a `Uri` variable.
    Dim fileUri As Uri = New Uri("https://pspdfkit.com/downloads/load-a-file/source.bmp")
    ' Specify the file format.
    Dim format As GdPicture14.DocumentFormat = GdPicture14.DocumentFormat.DocumentFormatBMP
    ' Load a bitmap image from a URL.
    gdpictureDocumentConverter.LoadFromHttp(fileUri, format)
    ' Save the PDF document to file.
    gdpictureDocumentConverter.SaveAsPDF("C:\temp\output.pdf")
End Using

To load and convert an SVG 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 SVG image.

  • DocumentFormat — The file format represented as a member of the DocumentFormat enumeration.

To load and convert an SVG 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.svg");
// Specify the file format.
GdPicture14.DocumentFormat format = GdPicture14.DocumentFormat.DocumentFormatSVG;
// Load an SVG image from a URL.
gdpictureDocumentConverter.LoadFromHttp(fileUri, format);
// Save the PDF document to file.
gdpictureDocumentConverter.SaveAsPDF(@"C:\temp\output.pdf");
Using gdpictureDocumentConverter As GdPictureDocumentConverter = New GdPictureDocumentConverter()
    ' Create a `Uri` variable.
    Dim fileUri As Uri = New Uri("https://pspdfkit.com/downloads/load-a-file/source.svg")
    ' Specify the file format.
    Dim format As GdPicture14.DocumentFormat = GdPicture14.DocumentFormat.DocumentFormatSVG
    ' Load an SVG image from a URL.
    gdpictureDocumentConverter.LoadFromHttp(fileUri, format)
    ' Save the PDF document to file.
    gdpictureDocumentConverter.SaveAsPDF("C:\temp\output.pdf")
End Using

To load and convert a TIFF 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 a TIFF image.

  • DocumentFormat — The file format represented as a member of the DocumentFormat enumeration.

To load and convert a TIFF 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.tiff");
// Specify the file format.
GdPicture14.DocumentFormat format = GdPicture14.DocumentFormat.DocumentFormatTIFF;
// Load a TIFF image from a URL.
gdpictureDocumentConverter.LoadFromHttp(fileUri, format);
// Save the PDF document to file.
gdpictureDocumentConverter.SaveAsPDF(@"C:\temp\output.pdf");
Using gdpictureDocumentConverter As GdPictureDocumentConverter = New GdPictureDocumentConverter()
    ' Create a `Uri` variable.
    Dim fileUri As Uri = New Uri("https://pspdfkit.com/downloads/load-a-file/source.tiff")
    ' Specify the file format.
    Dim format As GdPicture14.DocumentFormat = GdPicture14.DocumentFormat.DocumentFormatTIFF
    ' Load a TIFF image from a URL.
    gdpictureDocumentConverter.LoadFromHttp(fileUri, format)
    ' Save the PDF document to file.
    gdpictureDocumentConverter.SaveAsPDF("C:\temp\output.pdf")
End Using

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

  • HttpUri — A Uri variable pointing to any file.

  • DocumentFormat — The file format represented as a member of the DocumentFormat enumeration.

To load and convert an Excel file 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.xlsx");
// Specify the file format.
GdPicture14.DocumentFormat format = GdPicture14.DocumentFormat.DocumentFormatXLSX;
// Load an Excel file from a URL.
gdpictureDocumentConverter.LoadFromHttp(fileUri, format);
// Save to a PDF document.
gdpictureDocumentConverter.SaveAsPDF(@"C:\temp\output.pdf");
Using gdpictureDocumentConverter As GdPictureDocumentConverter = New GdPictureDocumentConverter()
    ' Create a `Uri` variable.
    Dim fileUri As Uri = New Uri("https://pspdfkit.com/downloads/load-a-file/source.xlsx")
    ' Specify the file format.
    Dim format As GdPicture14.DocumentFormat = GdPicture14.DocumentFormat.DocumentFormatXLSX
    ' Load an Excel file from a URL.
    gdpictureDocumentConverter.LoadFromHttp(fileUri, format)
    ' Save to a PDF document.
    gdpictureDocumentConverter.SaveAsPDF("C:\temp\output.pdf")
End Using