Skip to content

Instantly share code, notes, and snippets.

@M-Yankov
Last active January 14, 2020 11:13
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 M-Yankov/49b5588bb4e6528cf1e966dc3132c0ef to your computer and use it in GitHub Desktop.
Save M-Yankov/49b5588bb4e6528cf1e966dc3132c0ef to your computer and use it in GitHub Desktop.
A code that generates a PDF document for testing (requires iTextSharp)
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