using (var outStream = File.Create("sample.pdf"))
{
// Create a new PDF document.
PdfDocument document = new PdfDocument();
// Load the image from the disk.
using (var ifs = File.Open("../../syncfusion_logo.gif", FileMode.Open))
{
PdfBitmap image = new PdfBitmap(ifs);
var sw = Stopwatch.StartNew();
for (var p = 0; p < 100; p++)
{
// Add a page to the document.
PdfPage page = document.Pages.Add();
// Create PDF graphics for the page.
PdfGraphics graphics = page.Graphics;
// Draw the image
graphics.DrawImage(image, 0, 0, 200, 200);
}
}
// Save the document.
document.Save(outStream);
}
|
using (var outStream = File.Create("sample.pdf")) { var sw = Stopwatch.StartNew(); long prev = 0; long curr = 0; // Create a new PDF document. PdfDocument document = new PdfDocument(); // Load the image from the disk. using (var ifs = File.Open("./syncfusion-logo.png", FileMode.Open)) { PdfBitmap image = new PdfBitmap(ifs); for (var p = 0; p < 20000; p++) { // Add a page to the document. PdfPage page = document.Pages.Add(); // Create PDF graphics for the page. PdfGraphics graphics = page.Graphics; // Draw the image graphics.DrawImage(image, 0, 0, 200, 200); if (p > 0 && p % 1000 == 0) { curr = sw.ElapsedMilliseconds; Console.WriteLine($"Page {p} / {20000}: {curr - prev}ms"); prev = sw.ElapsedMilliseconds; ; } } curr = sw.ElapsedMilliseconds; Console.WriteLine($"Page {20000} / {20000}: {curr - prev}ms"); } // Save the document. document.Save(outStream); // Close the document. document.Close(true); } | Page 1000 / 20000: 101ms Page 2000 / 20000: 125ms Page 3000 / 20000: 188ms Page 4000 / 20000: 189ms Page 5000 / 20000: 214ms Page 6000 / 20000: 299ms Page 7000 / 20000: 354ms Page 8000 / 20000: 373ms Page 9000 / 20000: 419ms Page 10000 / 20000: 556ms Page 11000 / 20000: 620ms Page 12000 / 20000: 665ms Page 13000 / 20000: 864ms Page 14000 / 20000: 886ms Page 15000 / 20000: 1137ms Page 16000 / 20000: 1251ms Page 17000 / 20000: 1492ms Page 18000 / 20000: 1816ms Page 19000 / 20000: 1332ms Page 20000 / 20000: 1250ms |