PDF to PNG

Convert PDF to PNG with .NET REST API.

Unlock a new level of versatility and visual impact by converting your PDF files to PNG images. Develop online PDF viewer by utilizing the ability to generate high-quality images from PDF documents. Easy and simple steps to create stunning visuals, share content easily, and enhance your digital projects to the next level. So, if you are looking to showcase specific pages, preserve image quality, or improve compatibility across platforms, converting PDF to PNG opens up a new world of possibilities. In this article, we will explore how you can leverage the power of .NET REST API for seamless conversion of PDF to PNG for more dynamic and visually engaging way.

PDF Processing REST API

Aspose.PDF Cloud SDK for .NET offers a robust and reliable solution for converting PDF to PNG. The SDK offers a comprehensive set of methods and options to customize the conversion according to your specific needs. Whether you want to extract specific pages, set image resolution, or adjust image quality, the Aspose.PDF Cloud SDK provides the flexibility and control to achieve your desired results. Leveraging the cloud infrastructure, this SDK ensures fast and efficient processing, allowing you to convert PDF to PNG with ease.

Now, simply search Aspose.PDF-Cloud in NuGet packages manager inside Visual Studio IDE and click the Add Package button. The next important steps is to obtain your client credentials from cloud dashboard. In case you do not have an existing account, simply create a free account by following the instructions specified over quick start.

PDF to PNG using C# .NET

Let’s explore the details and code snippet to accomplish the requirement of converting PDF to PNG format. Please try using the following code snippet to convert PDF to PNG images.

Given below are the details regarding above stated code snippet.

PdfApi pdfApi = new PdfApi(clientSecret, clientID);

Firstly, create an object of PdfApi class while passing client credentials as input arguments.

var response = pdfApi.GetPageConvertToPng(inputFile, 1, width: 800, height: 1000);

Call the API to load a PDF file from cloud storage and convert 1st page to PNG format.

saveToDisk(response, "/Users/nayyer/Downloads/Converted.png");

Our custom method to save the resultant PNG to local drive.

convert pdf to png

PDF to PNG conversion preview.

The PDF document used in the above example can be downloaded from Binder1.pdf.

Convert PDF to PNG Online using cURL Commands

We can also accomplish the PDF to PNG conversion using cURL commands and Aspose.PDF Cloud API. With cURL, we can make HTTP requests directly to the API endpoints by providing the necessary parameters and authentication credentials. This approach offers flexibility and convenience, allowing us to integrate PDF to PNG conversion seamlessly into your existing workflows or applications.

The first step in this approach is the generation of a JWT access token. Please execute the following command:

curl -v "https://api.aspose.cloud/connect/token" \
 -X POST \
 -d "grant_type=client_credentials&client_id=bb959721-5780-4be6-be35-ff5c3a6aa4a2&client_secret=4d84d5f6584160cbd91dba1fe145db14" \
 -H "Content-Type: application/x-www-form-urlencoded" \
 -H "Accept: application/json"

Now, please execute the following command to convert the second page of PDF file to PNG format and save the output on local drive.

curl -v "https://api.aspose.cloud/v3.0/pdf/{inputFile}/pages/2/convert/png?width=800&height=1000" 
\ -X GET \
-H  "accept: multipart/form-data" \
-H  "authorization: Bearer {accessToken}" \
-o "converter.png"

Replace inputFile with the name of an input PDF document available in cloud storage, and accessToken with JWT access token generated above.

Conclusion

In conclusion, the conversion of PDF to PNG is a valuable feature that allows you to convert PDF pages to PNG images. Whether you choose to utilize the Aspose.PDF Cloud SDK for .NET or cURL commands with the Aspose.PDF Cloud API, both approaches provide efficient and reliable solutions. With the SDK, you have access to a comprehensive set of features and functionalities, simplifying the conversion process and offering additional capabilities for working with PDF files. On the other hand, cURL commands offer flexibility and integration possibilities, allowing a seamless automation and integration into existing workflows.

Whichever approach you choose, Aspose.PDF Cloud API empowers you to convert PDF to PNG effortlessly and unlocks the potential of PDF documents processing.

We highly recommend visiting the following blogs: