PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Drawing DrawMatrixCode : image is null
https://forum.pdfsharp.net/viewtopic.php?f=2&t=4279
Page 1 of 1

Author:  Hyrozen88 [ Mon Aug 02, 2021 11:50 am ]
Post subject:  Drawing DrawMatrixCode : image is null

Hello,
I can draw and write in my PDF without any problem.
Now, I want to generate a dataMatrix in a pdf with PdfSharp.
A problem occured when I run the DrawMatrixCode


// Version : 1.50.5147
Code:
using PdfSharp.Drawing;
using PdfSharp.Drawing.BarCodes;
using PdfSharp.Pdf;


Code:
PdfDocument document = new PdfDocument();
document.Info.Title = "Sample title";
PdfPage page = document.AddPage();
page.Width = XUnit.FromMillimeter(500);
page.Height = XUnit.FromMillimeter(500);
XGraphics gfx = XGraphics.FromPdfPage(page);
CodeDataMatrix dm = new CodeDataMatrix("test", 26)
{
    Size = new XSize(XUnit.FromMillimeter(15), XUnit.FromMillimeter(15))
};
gfx.DrawMatrixCode(dm, XBrushes.DarkBlue, new XPoint(100, 100));
// // ----> System.ArgumentNullException
//   HResult=0x80004003
//   Message=The value can't be
// Nparameter name : image
//   Source=PdfSharp
//   call stack :
//    à PdfSharp.Drawing.XGraphics.DrawImage(XImage image, Double x, Double y, Double width, Double height)
//    à PdfSharp.Drawing.BarCodes.CodeDataMatrix.Render(XGraphics gfx, XBrush brush, XPoint position)
//    à PdfSharp.Drawing.XGraphics.DrawMatrixCode(MatrixCode matrixcode, XBrush brush, XPoint position)

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/