PdfSharpCore icon indicating copy to clipboard operation
PdfSharpCore copied to clipboard

XGraphics.DrawMatrixCode fails with inappropriate error message

Open StepKie opened this issue 2 years ago • 3 comments

Somebody created this issue here, and I have the exact same issue when trying to draw a QR code image onto a pdf document:

https://forum.pdfsharp.net/viewtopic.php?f=2&t=4121

My code is basically the same:

string qrString = GetStringForQr(sample);
CodeDataMatrix qrCode = new CodeDataMatrix(qrString, , qrString.Length);
page.DrawMatrixCode(qrCode, QrCodeLocation);

The last line will throw

System.ArgumentNullException : Value cannot be null. (Parameter 'image')

Stack Trace: 
XGraphics.DrawImage(XImage image, Double x, Double y, Double width, Double height)
CodeDataMatrix.Render(XGraphics gfx, XBrush brush, XPoint position)
XGraphics.DrawMatrixCode(MatrixCode matrixcode, XPoint position)

, though the argument is obviously not null (can be verified with debugger).

StepKie avatar May 09 '23 11:05 StepKie

I have also the same problem. There is a solution? Thanks

amerlin avatar Jun 10 '23 17:06 amerlin

I have the same problem. When debugging I saw that the following method always returns null. I guess this is not a bug but not implemented at all.

PdfSharpCore/Drawing.BarCodes/DataMatrixImage.opensource.cs Line 179:

/// <summary>
/// Creates a DataMatrix image object.
/// </summary>
public XImage CreateImage(char[] code, int rows, int columns, int pixelsize)
{
    return null;
}

psycrush avatar Aug 01 '23 05:08 psycrush

https://github.com/ststeiger/PdfSharpCore/blob/c918cbf79c0f6c0e13d71fee551286357140b665/PdfSharpCore/Drawing.BarCodes/DataMatrixImage.opensource.cs#L181

@ststeiger Any possibility to fix this? Thanks...

StepKie avatar Sep 11 '23 10:09 StepKie