rdvojmoc / DinkToPdf

C# .NET Core wrapper for wkhtmltopdf library that uses Webkit engine to convert HTML pages to PDF.
MIT License
1.08k stars 414 forks source link

Barcode Label generation using Custom page size #112

Open Harshitsolanki opened 4 years ago

Harshitsolanki commented 4 years ago

Hi,

I need to print barcode labels using this to generate multiple barcodes Label size 4mmX 2mm. this label contains an QR Code and the product details .

Can you share how we can implement custom page size.

Regards Harshit

silvairsoares commented 10 months ago

Have you tried the custom paper size?

    globalSettings = new GlobalSettings
    {
        ColorMode = ColorMode.Color,
        Orientation = Orientation.Portrait,
        PaperSize = new PechkinPaperSize("XXmm", "XXmm"),
        Margins = new MarginSettings() { Top = MarginTop, Bottom = MarginBottom, Left = MarginLeft, Right = MarginRight },
        DocumentTitle = "Tag",
    };

    var pdf = new HtmlToPdfDocument()
    {
    GlobalSettings = globalSettings,
        Objects = { objectSettings }
    };

    file = await Task.Run(() => _pdfConverter.Convert(pdf));`

If you have already overcome this problem, what approach did you use?