pdf to jpg

How to convert PDF to JPG with .NET REST API.

Owing to the demand of a versatile and easily shareable visual content, the need to convert PDF documents to JPG images has become increasingly prevalent. Though the PDF files are commonly used for document preservation and distribution, they often pose limitations when it comes to web compatibility and multimedia integration. Therefore, the imperative need for PDF to JPG conversion, a transformative process that bridges the gap between static documents and dynamic visual content. In this article, we’ll explore the benefits and methods of PDF to JPG conversion using .NET REST API, empowering you to unlock the full potential of your digital content with ease.

PDF to JPG Conversion API

The conversion of PDF documents to JPG images is simplified and streamlined with Aspose.PDF Cloud SDK for .NET. This robust SDK not only facilitates seamless PDF to JPG conversion but also offers a wide range of advanced capabilities for comprehensive document manipulation. Furthermore, with Aspose.PDF Cloud SDK, developers can initiate the conversion process effortlessly, preserving the integrity of the resulting JPG images and ensuring accurate representation of the content.

In order to use the SDK, search Aspose.Pdf-Cloud in NuGet packages manager and click the Add Package button. This will add the SDK reference in your project. Secondly, obtain your client credentials from cloud dashboard. If you do not have an existing account, simply create a free account by following the instructions specified in the quick start article.

Convert PDF Format to JPG in C# .NET

The following section explains the details on how to achieve an efficient PDF to JPG conversion using C# .NET.

PdfApi pdfApi = new PdfApi(clientSecret, clientID);

Create an object of PdfApi class where we pass client credentials as arguments.

pdfApi.UploadFile("sourceFile.pdf", stream);

Upload the input PDF file to cloud storage.

pdfApi.GetPageConvertToJpeg("sourceFile.pdf", pageNumber, width: 600, height: 800);

Call API to convert the first PDF page to JPG image in specified dimensions.

pdf to jpg

A preview of PDF to JPG conversion.

The sample PDF file and the resultant JPG generated in above example can be downloaded from binder.pdf and myResultant.jpg

  • You may consider using our free online Image Viewer to preview the resultant JPG image.

Convert PDF to Picture using cURL Commands

The conversion of PDF documents to JPG images using Aspose.PDF Cloud and cURL commands provides a straightforward and efficient solution for document conversion. This approach ensures accuracy in preserving the quality and layout of the resultant JPG images, maintaining the integrity of the original PDF content. Furthermore, its cloud-based architecture ensures scalability and accessibility, allowing you to handle document conversion tasks efficiently without the need for complex local installations.

The first step in this approach is to generate a JWT access token using the following command:

curl -v "https://api.aspose.cloud/connect/token" \
 -X POST \
 -d "grant_type=client_credentials&client_id=163c02a1-fcaa-4f79-be54-33012487e783&client_secret=c71cfe618cc6c0944f8f96bdef9813ac" \
 -H "Content-Type: application/x-www-form-urlencoded" \
 -H "Accept: application/json"

Now, please execute the following command to convert PDF to picture format and store the output on local drive.

curl -v "https://api.aspose.cloud/v3.0/pdf/sourceFile.pdf/pages/1/convert/jpeg?width=600&height=800" \
-X GET \
-H "accept: multipart/form-data" \
-H "authorization: Bearer {accessToken}" \
-o "resultant.jpg"

In case we need to load the PDF file from cloud storage and also want to store the output in cloud storage, please execute the following command.

curl -v "https://api.aspose.cloud/v3.0/pdf/{sourceFile}/pages/2/convert/jpeg?outPath={resultantFile}&width=800&height=1000" \
-X PUT \
-H "accept: application/json" \
-H "authorization: Bearer {accessToken}" \
-d {}

Replace sourceFile with the name of input PDF file available in cloud storage, resultantFile with the name of resultant JPG image and, accessToken with JWT access token generated above.

Conclusion

In conclusion, the process of converting PDF documents to JPG images stands as a pivotal aspect of modern document management and content distribution. Throughout this discussion, we’ve explored various approaches to achieve this conversion, ranging from leveraging the Aspose.PDF Cloud SDK for .NET to utilizing cURL commands with Aspose.PDF Cloud API. Regardless of the method chosen, we can easily achieve our goal to streamline the document processing workflows and unlock the full potential of digital content.

We highly recommend visiting the following blog posts for information on: