Skip to content

Instantly share code, notes, and snippets.

@aspose-cloud
Last active June 19, 2021 12:01
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save aspose-cloud/d6e3c8316787d29fbb72d91bee2f4eaa to your computer and use it in GitHub Desktop.
This Gist contains code snippets related insertion of JPEG to PDF and then conversion of PDF to JPEG format

This gist contains code snippets related to merger of JPEG (raster Images) using Aspose.PDF Cloud SDK for .NET. In order to accomplish the requirement,

  • First, create a blank PDF file
  • Insert 1st image at specified coordinate
  • Insert 2nd image at specified coordinate
  • Insert 3rd image at specified coordinate
  • Insert 4th image at specified coordinate
  • Finaly convert the PDF file to image format

Please visit the following link for more details on

string clientID = "718e4235-8866-4ebe-bff4-f5a14a4b6466"; // Get ClientID from https://dashboard.aspose.cloud/
string clientSecret = "388e864b819d8b067a8b1cb625a2ea8e"; // Get CLientSecret from https://dashboard.aspose.cloud/
// file name for PDF to be created
String fileName = "input.pdf";
// create an instance of PdfApi
PdfApi pdfApi = new PdfApi(clientSecret, clientID);
// Invoke Aspose.PDF Cloud SDK API to create empty pdf file
DocumentResponse apiResponse = pdfApi.PutCreateDocument(fileName);
// page number of PDF file
int pageNumber = 1;
// Insert 1st image in PDF on specified cooridnates
// The cooridnates are in Point starting from Bottom-Left to Top-Right
pdfApi.PostInsertImage(fileName, pageNumber, 10, 850, 310, 650, "Flower-Backgrounds.jpg");
// Insert 2nd image in PDF on specified cooridnates
pdfApi.PostInsertImage(fileName, pageNumber, 320, 850, 600, 650, "png-vs-jpeg.jpg");
// Insert 3rd image in PDF on specified cooridnates
pdfApi.PostInsertImage(fileName, pageNumber, 10, 620, 310, 420, "purple_flowers_201054.jpg");
// Insert 4th image in PDF on specified cooridnates
pdfApi.PostInsertImage(fileName, pageNumber, 320, 620, 600, 420, "Forest.jpg");
// convert PDF file to JPEG format and save on Cloud storage
var finalResponse = pdfApi.PutPageConvertToJpeg(fileName,pageNumber,"FinalConverted.jpeg");
if (finalResponse != null && finalResponse.Status.Equals("OK"))
{
Console.WriteLine("PDF Converted to JPEG, Done!");
Console.ReadKey();
}
This Gist contains code snippets related insertion of JPEG to PDF and then conversion of PDF to JPEG format.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment