Skip to content

Instantly share code, notes, and snippets.

@GroupDocsGists
Last active May 19, 2021 11:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GroupDocsGists/b19804d541cddbe28869fd02e067c42a to your computer and use it in GitHub Desktop.
Save GroupDocsGists/b19804d541cddbe28869fd02e067c42a to your computer and use it in GitHub Desktop.
Convert Images to PDF in C#
// Convert any Image to PDF in C#. PNG, WebP, JPG, GIF, TGA and many more ...
using (Converter converter = new Converter("image.png"))
{
PdfConvertOptions options = new PdfConvertOptions();
converter.Convert("imageToPdf.pdf", options);
}
// Convert JPG, PNG or other Images to PDF in C#. Resize, Set margins, or rotate images.
using (Converter converter = new Converter("image.jpg"))
{
PdfConvertOptions options = new PdfConvertOptions
{
Width = 233,
Height = 175,
MarginTop = 20,
MarginBottom = 20,
MarginLeft = 20,
MarginRight = 20,
Rotate = Rotation.On180
};
converter.Convert("imageToPdfAdv.pdf", options);
}
// Convert JPG Image to PDF in C#
using (Converter converter = new Converter("image.jpg"))
{
PdfConvertOptions options = new PdfConvertOptions();
converter.Convert("imageToPdf.pdf", options);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment