EVO HTML to PDF Converter allows you to add text notes to a PDF document. The text notes are created by adding EvoPdfClientTextNoteElement objects to a PDF document. You can add text notes with various types of icons to a PDF document. Also, the text notes can be initially in an open or closed state.
Code Sample - Add Text Notes to a PDF Document
C#
using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Http; // Use EVO PDF Namespace using EvoPdfClient; namespace EvoHtmlToPdfDemo.Controllers.PDF_Creator { public class PDF_Creator_Text_NotesController : Controller { // GET: PDF_Creator_Text_Notes public ActionResult Index() { return View(); } [HttpPost] public ActionResult CreatePdf(IFormCollection collection) { // Get the server options string serverIP = collection["textBoxServerIP"]; uint serverPort = uint.Parse(collection["textBoxServerPort"]); string servicePassword = collection["textBoxServicePassword"]; bool useServicePassword = servicePassword.Length > 0; bool useTcpService = collection["ServerType"] == "radioButtonUseTcpService"; string webServiceUrl = collection["textBoxWebServiceUrl"]; // Create a PDF document Document pdfDocument = null; if (useTcpService) pdfDocument = new Document(serverIP, serverPort); else pdfDocument = new Document(true, webServiceUrl); // Set optional service password if (useServicePassword) pdfDocument.ServicePassword = servicePassword; // Set license key received after purchase to use the converter in licensed mode // Leave it not set to use the converter in demo mode pdfDocument.LicenseKey = "4W9+bn19bn5ue2B+bn1/YH98YHd3d3c="; // Add a page to PDF document PdfPage pdfPage = pdfDocument.AddPage(); // The titles font used to mark various sections of the PDF document PdfFont titleFont = new PdfFont("Times New Roman", 10, true); titleFont.Bold = true; PdfFont subtitleFont = new PdfFont("Times New Roman", 8, true); // Add document title TextElement titleTextElement = new TextElement(5, 5, "Add Text Notes to a PDF Document", titleFont); pdfPage.AddElement(titleTextElement); // Add the text element string text = "Click the next icon to open the the text note:"; TextElement textElement = new TextElement(0, 0, 200, text, subtitleFont); pdfDocument.AddElement(textElement, 10); RectangleFloat textNoteRectangle = new RectangleFloat(0, 0, 10, 10); // Create the text note TextNoteElement textNoteElement = new TextNoteElement(textNoteRectangle, "This is an initially closed text note"); textNoteElement.NoteIcon = TextNoteIcon.Note; textNoteElement.Open = false; pdfDocument.AddElement(textNoteElement, 10, true, false, 0, true, false); // Add the text element text = "This is an already opened text note:"; textElement = new TextElement(0, 0, 200, text, subtitleFont); pdfDocument.AddElement(textElement, 5, false, 10, true); textNoteRectangle = new RectangleFloat(0, 0, 10, 10); // Create the text note TextNoteElement textNoteOpenedElement = new TextNoteElement(textNoteRectangle, "This is an initially opened text note"); textNoteOpenedElement.NoteIcon = TextNoteIcon.Note; textNoteOpenedElement.Open = true; pdfDocument.AddElement(textNoteOpenedElement, 10, true, false, 0, true, false); // Add the text element text = "Click the next icon to open the the help note:"; textElement = new TextElement(0, 0, 200, text, subtitleFont); pdfDocument.AddElement(textElement, 5, false, 10, true); textNoteRectangle = new RectangleFloat(0, 0, 10, 10); // Create the text note TextNoteElement helpNoteElement = new TextNoteElement(textNoteRectangle, "This is an initially closed help note"); helpNoteElement.NoteIcon = TextNoteIcon.Help; helpNoteElement.Open = false; pdfDocument.AddElement(helpNoteElement, 10, true, false, 0, true, false); // Add the text element text = "This is an already opened help note:"; textElement = new TextElement(0, 0, 200, text, subtitleFont); pdfDocument.AddElement(textElement, 5, false, 10, true); textNoteRectangle = new RectangleFloat(0, 0, 10, 10); // Create the text note TextNoteElement helpNoteOpenedElement = new TextNoteElement(textNoteRectangle, "This is an initially opened help note"); helpNoteOpenedElement.NoteIcon = TextNoteIcon.Help; helpNoteOpenedElement.Open = true; pdfDocument.AddElement(helpNoteOpenedElement, 10, true, false, 0, true, false); // Add the text element text = "Click the next icon to open the comment:"; textElement = new TextElement(0, 0, 200, text, subtitleFont); pdfDocument.AddElement(textElement, 5, false, 10, true); textNoteRectangle = new RectangleFloat(0, 0, 10, 10); // Create the text note TextNoteElement commentNoteElement = new TextNoteElement(textNoteRectangle, "This is an initially closed comment note"); commentNoteElement.NoteIcon = TextNoteIcon.Comment; commentNoteElement.Open = false; pdfDocument.AddElement(commentNoteElement, 10, true, false, 0, true, false); // Add the text element text = "This is an already opened comment:"; textElement = new TextElement(0, 0, 200, text, subtitleFont); pdfDocument.AddElement(textElement, 5, false, 10, true); textNoteRectangle = new RectangleFloat(0, 0, 10, 10); // Create the text note TextNoteElement commentNoteOpenedElement = new TextNoteElement(textNoteRectangle, "This is an initially opened comment note"); commentNoteOpenedElement.NoteIcon = TextNoteIcon.Comment; commentNoteOpenedElement.Open = true; pdfDocument.AddElement(commentNoteOpenedElement, 10, true, false, 0, true, false); // Add the text element text = "Click the next icon to open the paragraph note: "; textElement = new TextElement(0, 0, 200, text, subtitleFont); pdfDocument.AddElement(textElement, 5, false, 10, true); textNoteRectangle = new RectangleFloat(0, 0, 10, 10); // Create the text note TextNoteElement paragraphNoteElement = new TextNoteElement(textNoteRectangle, "This is an initially closed paragraph note"); paragraphNoteElement.NoteIcon = TextNoteIcon.Paragraph; paragraphNoteElement.Open = false; pdfDocument.AddElement(paragraphNoteElement, 10, true, false, 0, true, false); // Add the text element text = "Click the next icon to open the new paragraph note:"; textElement = new TextElement(0, 0, 200, text, subtitleFont); pdfDocument.AddElement(textElement, 5, false, 10, true); textNoteRectangle = new RectangleFloat(0, 0, 10, 10); // Create the text note TextNoteElement newParagraphNoteElement = new TextNoteElement(textNoteRectangle, "This is an initially closed new paragraph note"); newParagraphNoteElement.NoteIcon = TextNoteIcon.NewParagraph; newParagraphNoteElement.Open = false; pdfDocument.AddElement(newParagraphNoteElement, 10, true, false, 0, true, false); // Add the text element text = "Click the next icon to open the key note:"; textElement = new TextElement(0, 0, 200, text, subtitleFont); pdfDocument.AddElement(textElement, 5, false, 10, true); textNoteRectangle = new RectangleFloat(0, 0, 10, 10); // Create the text note TextNoteElement keyNoteElement = new TextNoteElement(textNoteRectangle, "This is an initially closed key note"); keyNoteElement.NoteIcon = TextNoteIcon.Key; keyNoteElement.Open = false; pdfDocument.AddElement(keyNoteElement, 10, true, false, 0, true, false); // Save the PDF document in a memory buffer byte[] outPdfBuffer = pdfDocument.Save(); // Send the PDF file to browser FileResult fileResult = new FileContentResult(outPdfBuffer, "application/pdf"); fileResult.FileDownloadName = "Text_Notes.pdf"; return fileResult; } } }