Last active
January 14, 2020 11:13
-
-
Save M-Yankov/49b5588bb4e6528cf1e966dc3132c0ef to your computer and use it in GitHub Desktop.
A code that generates a PDF document for testing (requires iTextSharp)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using iText.Kernel.Colors; | |
using iText.Kernel.Pdf; | |
using iText.Layout; | |
using iText.Layout.Element; | |
public class Program | |
{ | |
public static void Main(string[] args) => | |
new Document(new PdfDocument(new PdfWriter(new FileStream( | |
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), $"{Guid.NewGuid()}.pdf"), | |
FileMode.Create, | |
FileAccess.ReadWrite)))) | |
.Add(new Paragraph($"Testing document: {DateTime.Now.ToString("dd-MMM-yyyy HH:mm:ss")}").SetBackgroundColor(new DeviceRgb( | |
new Random().Next(122, 255), | |
new Random().Next(122, 255), | |
new Random().Next(122, 255)))) | |
.Close(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment