BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
doc.PageSettings.Orientation = PdfPageOrientation.Landscape;
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Load the image from the disk.
PdfBitmap image = new PdfBitmap(imagePath);
SizeF pageSize = page.GetClientSize();
//Setting image bounds
RectangleF imageBounds = new RectangleF(0, 0, pageSize.Width, pageSize.Height);
//Draw the image
graphics.DrawImage(image, imageBounds);
//Save the document.
doc.Save(DataPathOutput+"Output.pdf");
//Close the document.
doc.Close(true); |
'Create PDF document
Dim doc As PdfDocument = New PdfDocument()
'Set orientation
doc.PageSettings.Orientation = PdfPageOrientation.Landscape
'Add page
Dim page As PdfPage = doc.Pages.Add()
'Create graphics
Dim graphics As PdfGraphics = page.Graphics
'Load the image from disk
Dim image As PdfBitmap = New PdfBitmap(imagePath);
'Get page size
Dim pageSize As SizeF = page.GetClientSize()
'Setting image bounds
Dim imageBounds As RectangleF = New RectangleF(0, 0, pageSize.Width, pageSize.Height)
'Draw the image
graphics.DrawImage(image, imageBounds)
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)
Process.Start("Output.pdf") |