PDF files have become ubiquitous in the digital world, serving as a universal format for sharing documents across various platforms and devices. Their ability to maintain formatting and ensure consistency regardless of the viewing environment has made them indispensable in numerous industries and applications. However, there are instances where converting PDF files to other formats becomes necessary, particularly when it comes to sharing or presenting information in a more visually accessible manner. Therefore, by converting PDF documents to JPG images, you can easily extract specific pages or elements from PDF files and incorporate them into presentations, reports, or web content. Let’s explore the details on how we can transform PDF document to JPG using REST API.
PDF to JPG Conversion SDK
With GroupDocs.Conversion Cloud SDK for .NET, achieving PDF to JPG conversion is both seamless and efficient. This Cloud SDK ensures high-quality conversion results, preserving the layout, formatting, and clarity of the PDF content throughout the process. Therefore, with just a few lines of code, you can initiate the conversion process, specify the input PDF file, and receive the resulting JPG images without bothering about the complexities of setup and configurations.
Now, in order to use the SDK, the first step is its installation. So, search GroupDocs.Conversion-Cloud in NuGet package manager and click the Install button. Another option is to execute the following command in package manager console.
NuGet\Install-Package GroupDocs.Conversion-Cloud -Version 24.2.0
The next important step is to obtain client credentials (i.e. Client ID and Client Secret). Therefore, please visit this short tutorial for information on how to get the client credentials.
Convert PDF to JPG using C# .NET
In this section, we are going to explore the details on achieving seamless PDF document to JPG conversion using C# .NET.
- Create an instance of
Configuration
class where we pass client credentials as arguments.
var configurations = new Configuration(clientId, clientSecret1);
- Initialize the
ConvertApi
where we pass Configuration object as an input argument.
var apiInstance = new ConvertApi(configurations);
- Upload the input PDF file to cloud storage while passing the name of the input PDF document.
fileUpload.UploadFile(new UploadFileRequest("input.pdf", stream));
- Create an instance
ConvertSettings
where we specify the name for input PDF, output format asjpg
and the name for resultant JPEG image.
var settings = new ConvertSettings{...}
- Call the ConvertDocumentRequest API to convert PDF into JPG format. After successful conversion, the resultant JPG image is stored in cloud storage.
var response = apiInstance.ConvertDocument(new ConvertDocumentRequest(settings));
The sample PDF file used in the above example can be downloaded from input.pdf.
PDF to Image using cURL Commands
If you prefer command-line interfaces or require batch conversion capabilities, we can accomplish PDF document to JPG conversion using GroupDocs.Conversion Cloud and cURL commands, as they offer a straightforward and efficient solution. With cURL commands, you can easily initiate the conversion process, specify the input PDF file, and receive the resulting JPG images—all without the need for complex coding or integration.
The first step in this approach is to obtain your personalized credentials (App Key and App SID) and generate JWT access token. Once we have JWT token, please execute the following cURL command to convert PDF to image.
curl -v "https://api.groupdocs.cloud/v2.0/conversion" \
-X POST \
-H "accept: application/json" \
-H "authorization: Bearer {accessToken}" \
-H "Content-Type: application/json" \
-d "{ \"FilePath\": \"{inputFile}\", \"Format\": \"jpg\", \"LoadOptions\": { \"Format\": \"JPG\" },\"OutputPath\": \"{resultantFile}\"}"
Please replace inputFile
with the name of input PDF document available in cloud storage, resultantFile
with the name of output JPG image and accessToken
with JWT token generated above. After successful conversion, the resultant file is saved to cloud storage.
Free PDF to JPG Conversion App
Are you looking for a free PDF to JPG conversion App ? Please try using our out of the box, lightweight and super-efficient PDF to JPG Converter application which is developed on top of GroupDocs.Conversion API.
Frequently Asked questions
How to convert PDF to PNG?
- GroupDocs.Conversion Cloud SDK is equally capable of converting PDF to PNG format. For further details, please visit Convert PDF to PNG with REST API.
Can I access the source code of conversion API?
- The complete source code of GroupDocs.Conversion Cloud SDK for .NET can be downloaded from GitHub repository.
Useful Links
Conclusion
In summary, whether you opt for GroupDocs.Conversion Cloud SDK for .NET or utilize cURL commands with GroupDocs.Conversion Cloud, the conversion of PDF document in to JPG is a seamless process. Both methods provide efficient solutions for automating document conversion tasks, offering flexibility and reliability. So, regardless of the chosen method, both approaches empower you to effortlessly convert PDF to JPG and streamline your document processing workflows with ease.
Related Articles
We highly recommend visiting the following links to learn more about: