itext pdfimage library

This commit is contained in:
Marco Giuntoni
2024-03-01 16:00:16 +01:00
parent 4cbbee5147
commit 0c24ec1cbb
9 changed files with 502 additions and 400 deletions
+29
View File
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace itext.pdfimage.Extensions
{
public static class MeasuringExtensions
{
//72 points == 1
//72px x 72px is 1inch x 1inch at a 72dpi resolution
public static int Dpi { get; set; } = 300;
public static float PixelsToPoints(this float value, int? dpi = null)
{
return value / (dpi ?? Dpi) * 72;
}
public static int PointsToPixels(this int value, int? dpi = null)
{
return PointsToPixels((float)value);
}
public static int PointsToPixels(this float value, int? dpi = null)
{
return (int)(value * (dpi ?? Dpi) / 72);
}
}
}