This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /guides/dotnet/pdf-generation/byte-array.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. Create PDF from byte array | Nutrient .NET SDK

To create a PDF document from a byte array, follow the steps below:

Download sample
  1. Create a GdPicturePDF object and a GdPictureImaging object.
  2. Load the source byte array by passing the byte array to the CreateGdPictureImageFromByteArray method of the GdPictureImaging object.
  3. Create the output PDF document with the NewPDF method of the GdPicturePDF object.
  4. Add the image to the output PDF document with the AddImageFromGdPictureImage method of the GdPicturePDF object.
  5. Save the output PDF document with the SaveToFile method of the GdPicturePDF object.
  6. Release unnecessary resources.

The following code creates a PDF document from a byte array based on an image source:

Register the SDK license before running SDK operations. For setup details, refer to the getting started with .NET SDK guide.

using GdPicture14;
LicenseManager license = new LicenseManager();
license.RegisterKEY("");
using GdPicturePDF gdpicturePDF = new GdPicturePDF();
using GdPictureImaging gdpictureImaging = new GdPictureImaging();
// Create a byte array from an image file.
byte[] byteArray = File.ReadAllBytes(@"input.png");
// Load the source byte array.
int imageId = gdpictureImaging.CreateGdPictureImageFromByteArray(byteArray);
// Create the output PDF document.
gdpicturePDF.NewPDF();
// Add the image to the output PDF document.
gdpicturePDF.AddImageFromGdPictureImage(imageId, false, true);
// Save the output PDF document.
gdpicturePDF.SaveToFile(@"output.pdf");
// Release unnecessary resources.
gdpicturePDF.CloseDocument();
gdpictureImaging.ReleaseGdPictureImage(imageId);