empira / PDFsharp

PDFsharp and MigraDoc Foundation for .NET 6 and .NET Framework
https://docs.pdfsharp.net/
Other
398 stars 91 forks source link

How to convert Byte[] to XImage in PdfSharp #100

Closed Adhikesevan closed 3 months ago

Adhikesevan commented 3 months ago

I have used gfx.DrawBarCode() method to draw the QR code in PDF document but its not working. I have shared the drawing code for your reference.

Reporting an Issue Here

Expected Behavior

The Bar code (QR -Code) is needs to be generated for the CodeType 'DataMatrix' and its need to be drawn in the Pdf by using the DrawBarcode method.

Actual Behavior

Throws InvalidEnumArgumentException while creating the DataMatrix bar code .

Steps to Reproduce the Behavior

var gfx = XGraphics.FromPdfPage(pdf.Pages[0], XPageDirection.Downwards); BarCode barCode = BarCode.FromType(CodeType.DataMatrix, "Sample QR Text"); gfx.DrawBarCode(barCode, new XPoint(0, 0));

image

palanisamy-emis commented 3 months ago

@ThomasHoevel could you please have a look at the above query. We need a solution for this. Thanks

ThomasHoevel commented 3 months ago

See here: https://stackoverflow.com/a/22323300

Adhikesevan commented 3 months ago

HI @ThomasHoevel ,

While using the suggestion in the link itself throwing an error like "The given data and encoding combination is too big for the matrix size.", Do you have an working sample for this?

image