PDFsharp & MigraDoc Foundation https://forum.pdfsharp.net/ |
|
Cannot generate Matrix Code/QR code on PDF using PDFSharp https://forum.pdfsharp.net/viewtopic.php?f=2&t=4121 |
Page 1 of 1 |
Author: | chanandrew96 [ Wed Apr 01, 2020 2:16 pm ] |
Post subject: | Cannot generate Matrix Code/QR code on PDF using PDFSharp |
I import the PDFSharp 1.50.5147 version using NuGet and tried to generate the matrix code using the code below Code: var myXSize = new XSize(130, 130); var myNewCode = new PdfSharp.Drawing.BarCodes.CodeDataMatrix("Content", 144, myXSize); var myXPoint = new XPoint(630, 50); //gfx.DrawMatrixCode(myNewCode, myXPoint); But when I execute the code it return error "Value cannot be null. Parameter name: image" as below: Code: [ArgumentNullException: Value cannot be null. Parameter name: image] PdfSharp.Drawing.XGraphics.DrawImage(XImage image, Double x, Double y, Double width, Double height) +174 PdfSharp.Drawing.BarCodes.CodeDataMatrix.Render(XGraphics gfx, XBrush brush, XPoint position) +2637 PdfSharp.Drawing.XGraphics.DrawMatrixCode(MatrixCode matrixcode, XPoint position) +147 learners.pages.Class.ViewCompletedAssessment.btnDownloadCert_Click(Object sender, EventArgs e) in E:\Inetpub\wwwroot\learners\learners\pages\Class\ViewCompletedAssessment.aspx.cs:181 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +11758656 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +150 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5028 It seems that the "DrawMatrixCode" function will call "DrawImage" function and I dig the source code and found it should run the code below: Code: if (MatrixImage == null) MatrixImage = DataMatrixImage.GenerateMatrixImage(Text, Encoding, Rows, Columns); However, it seems that the image is not generated. Does anyone can come up with some advise? |
Author: | dracaenus [ Mon Mar 27, 2023 10:37 am ] |
Post subject: | Re: Cannot generate Matrix Code/QR code on PDF using PDFShar |
Hi there, I got the same Error when I used the package "PDFsharp" version "1.50.5147". But it worked with package "PDFsharp-gdi" version "1.50.5147" Hope this helps! |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |