The code sample is show below:
- Code: Select all
var mySvg = SvgDocument.FromSvg<SvgDocument>(data);
var bitmap = mySvg.Draw();
bitmap.Save(@"C:\Data\barcode.bmp");
PdfImage image = PdfImage.FromImage(bitmap);
PdfDocument doc = new PdfDocument();
PdfPageBase page = doc.Pages.Add();
float width = image.Width * 0.75f;
float height = image.Height * 0.75f;
float x = (page.Canvas.ClientSize.Width - width) / 2;
page.Canvas.DrawImage(image, x, 60, width, height);
doc.SaveToFile(@"C:\Data\barcode.pdf");
I am using the free spire pdf library and I have verified that barcode.bmp at line 3 has a visible image