java打印不能启用_无法使用MigraDoc / PDFsharp进行打印

我将NuGet包添加到我的项目中:

PDFsharp MigraDoc版本:1.50.4790-beta5a(预发布)

这增加了参考文献:

MigraDoc.DocumentObjectModel MigraDoc.Rendering MigraDoc.RtfRendering PdfSharp PdfSharp.Charting

我使用VS2013,目标是.NET Framework 4.5 .

没有 MigraDocPrintDocument 类/命名空间,也没有 Printing.MigraDocPrintDocument ......

此外,我试图在我的表单中添加一个 PagePreview 控件(我正在开发一个Windows.Forms应用程序)但是没有这样的控件也不能从dll / packages中将这样的项添加到我的工具箱中 .

我已经使PDF文档非常简单,但现在我仍然坚持这最后一步,我看不到光 . 需要打印到热敏打印机 .

我的代码的简短片段:

public void PrintMigraDoc(Bitmap ImagenBMP, string nombre, string apellido, string documento, string nacimiento, string nacionalidad, string grupo)

{

//Save image in greyscale

Bitmap bmp = GrayScale(ImagenBMP);

bmp.Save("foto_grey.bmp");

//Create document

Document document = new Document();

//Custom Normal Style

Style style = document.Styles["Normal"];

style.Font.Name = "Calibri";

style.Font.Size = 6;

//Sections & Page Properties

Section section = document.AddSection();

Unit width, height;

width = Unit.FromMillimeter(60);

height = Unit.FromMillimeter(100);

section.PageSetup.PageWidth = width;

section.PageSetup.PageHeight = height;

section.PageSetup.LeftMargin = 5;

section.PageSetup.RightMargin = 5;

section.PageSetup.TopMargin = 5;

//Fecha

Paragraph paragraph = section.AddParagraph(DateTime.Today.ToString("dddd") + ", " + DateTime.Today.ToString("dd MMMM yyyy"));

//Foto

paragraph = section.AddParagraph();

MigraDoc.DocumentObjectModel.Shapes.Image imagen = section.AddImage("foto_grey.bmp");

imagen.Width = "2.5cm";

imagen.LockAspectRatio = true;

imagen.Left = MigraDoc.DocumentObjectModel.Shapes.ShapePosition.Center;

paragraph = section.AddParagraph();

//Datos en Tabla

this.table = section.AddTable();

this.table.Borders.Width = 0.25;

this.table.Borders.Left.Width = 0.5;

this.table.Borders.Right.Width = 0.5;

this.table.Rows.LeftIndent = 0;

this.table.RightPadding = 0;

//Columnas

MigraDoc.DocumentObjectModel.Tables.Column column = this.table.AddColumn();

column = this.table.AddColumn();

//Filas

MigraDoc.DocumentObjectModel.Tables.Row row = table.AddRow();

//Nombre

paragraph = row.Cells[0].AddParagraph("Name: ");

paragraph.AddFormattedText(nombre, TextFormat.Bold);

row.Cells[0].MergeRight = 1;

//Apellido

row = table.AddRow();

paragraph = row.Cells[0].AddParagraph("Surename: ");

paragraph.AddFormattedText(apellido, TextFormat.Bold);

row.Cells[0].MergeRight = 1;

//Documento

row = table.AddRow();

paragraph = row.Cells[0].AddParagraph("Document: ");

paragraph.AddFormattedText(documento, TextFormat.Bold);

row.Cells[0].MergeRight = 1;

//Apellido

row = table.AddRow();

paragraph = row.Cells[0].AddParagraph("Birth Date: ");

paragraph.AddFormattedText(nacimiento, TextFormat.Bold);

paragraph = row.Cells[1].AddParagraph("Nationality: ");

paragraph.AddFormattedText(nacionalidad, TextFormat.Bold);

PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(false);

pdfRenderer.Document = document;

pdfRenderer.RenderDocument();

string filename = "Invoice.pdf";

pdfRenderer.PdfDocument.Save(filename);

// Creates a PrintDocument that simplyfies printing of MigraDoc documents

//MigraDocPrintDocument printDocument = new MigraDocPrintDocument();

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值