0% found this document useful (0 votes)
30 views2 pages

Create The Code For Generating A PDF Appointment Letter

Uploaded by

p.lavanyajanu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views2 pages

Create The Code For Generating A PDF Appointment Letter

Uploaded by

p.lavanyajanu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

using Syncfusion.

Pdf;
using Syncfusion.Pdf.Graphics;
using Syncfusion.Pdf.Grid;
using System.IO;
using Microsoft.AspNetCore.Mvc;

namespace YourNamespace.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class AppointmentLetterController : ControllerBase
{
[HttpGet]
[Route("GenerateAppointmentLetter")]
public IActionResult GenerateAppointmentLetter()
{
// Create a new PDF document.
PdfDocument document = new PdfDocument();
// Add a page to the document.
PdfPage page = document.Pages.Add();
// Create PDF graphics for the page.
PdfGraphics graphics = page.Graphics;
// Set the standard font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12);

// Add the header


graphics.DrawString("Appointment Letter", new
PdfStandardFont(PdfFontFamily.Helvetica, 18, PdfFontStyle.Bold), PdfBrushes.Black,
new PointF(0, 0));

// Add the body content


string bodyText = "Dear [EmployeeName],\n\nWe are delighted to offer
you the position of [JobTitle] " +
"at [CompanyName]. Your employment start date will be
[StartDate].\n\n" +
"The terms and conditions of your employment are as
follows:\n" +
"1. Your monthly salary will be [Salary].\n" +
"2. You will be entitled to [Benefits].\n" +
"3. Your working hours will be [WorkingHours].\n\n" +
"Please sign and return this letter by
[AcceptanceDate] as a confirmation of your acceptance.\n\n" +
"Sincerely,\n\n[YourName]\n[YourTitle]";

graphics.DrawString(bodyText, font, PdfBrushes.Black, new RectangleF(0,


40, page.GetClientSize().Width, page.GetClientSize().Height));

// Save the document to a memory stream.


MemoryStream stream = new MemoryStream();
document.Save(stream);
stream.Position = 0;

// Close the document.


document.Close(true);

// Define the content type and return the PDF document.


return File(stream, "application/pdf", "AppointmentLetter.pdf");
}
}
}

You might also like