0

I need to make a PDF report via PdfSharp. The report must include a QRCode, or data matrix code, but I can't seem to be able to draw it on the page.

The values it's asking for are value as String and length as Integer so here's what I'm doing:

Dim myNewCode As New PdfSharp.Drawing.BarCodes.CodeDataMatrix("1234567890", 10)

Then I try to draw it:

gfx.DrawMatrixCode(myNewCode, myXPoint)

It asks for an XPoint location so I set it to this:

Dim myXPoint As New XPoint(500,500)

Which only needs values for x and y.

It compiles OK but when I try to open the file I get the next error

An error exists on this page. Acrobat may not display the page correctly. Please contact the person who created the PDF document to correct the problem

My Acrobat version is 11.0.5, and there is no problem opening other PDF files which already contain these kind of codes.

user1676874
  • 875
  • 2
  • 24
  • 45

2 Answers2

1

Specify the size to get a correct PDF file:

var myXSize = new XSize(100, 100);
var myNewCode = new PdfSharp.Drawing.BarCodes.CodeDataMatrix("1234567890", 10, myXSize);
var myXPoint = new XPoint(200, 300);
gfx.DrawMatrixCode(myNewCode, myXPoint);

Please note that due to legal reasons, the open source version of PDFsharp does not include the implementation of the Data Matrix Code and shows dummy images instead.

0

Another option would be to use a 3rd party library (ZXing) to generate the QR Code bitmap and draw it as a bitmap with DrawImage() on the PDF.

Community
  • 1
  • 1
d.popov
  • 4,175
  • 1
  • 36
  • 47