1
1
using BinaryKits . Zpl . Label . Elements ;
2
2
using BinaryKits . Zpl . Viewer . ElementDrawers ;
3
+ using BinaryKits . Zpl . Viewer . Helpers ;
3
4
using SkiaSharp ;
4
5
using System ;
5
6
using System . Collections . Generic ;
@@ -10,6 +11,10 @@ namespace BinaryKits.Zpl.Viewer
10
11
{
11
12
public class ZplElementDrawer
12
13
{
14
+ private const int PdfDpi = 72 ;
15
+ private const float ZplDpi = 203.2f ;
16
+ private const float PdfScaleFactor = PdfDpi / ZplDpi ;
17
+
13
18
private readonly DrawerOptions _drawerOptions ;
14
19
private readonly IPrinterStorage _printerStorage ;
15
20
private readonly IElementDrawer [ ] _elementDrawers ;
@@ -110,7 +115,13 @@ public List<byte[]> DrawMulti(
110
115
// - When drawing PDF we need the Bitmap as well to fix inverted coloring
111
116
Stream pdfStream = new MemoryStream ( ) ;
112
117
using var document = SKDocument . CreatePdf ( pdfStream ) ;
113
- using var pdfCanvas = document . BeginPage ( labelImageWidth , labelImageHeight ) ;
118
+
119
+ using var pdfCanvas = document . BeginPage (
120
+ UnitsHelper . ConvertMillimetersToNearestInch ( labelWidth ) * PdfDpi ,
121
+ UnitsHelper . ConvertMillimetersToNearestInch ( labelHeight ) * PdfDpi ) ;
122
+
123
+ pdfCanvas . Scale ( PdfScaleFactor , PdfScaleFactor ) ;
124
+
114
125
if ( this . _drawerOptions . PdfOutput == true )
115
126
{
116
127
skCanvas . AddCanvas ( pdfCanvas ) ;
0 commit comments