我有一个应用程序打印您想要的条形码数量,但如果条形码的数量大于PrintDocument的大小,它不会跳转到下一页.
我想知道如何在PrintDocument的下一页中添加更多页面或写入.

我正在使用PrintPreview在此Windows窗体中显示PrintDocument.
我正在尝试MSDN使用PrintDocument打印的例子,但它并不是那么顺利.我已经完成了所有编译,但是当我点击打印时,会弹出"传真发送设置"窗口.这应该发生吗?我想打印,而不是发传真!
我需要更改什么才能直接打印到默认打印机?
谢谢!
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Drawing.Printing;
namespace WindowsFormsApplication1
{
public partial class Form4 : System.Windows.Forms.Form
{
private System.ComponentModel.Container components;
private System.Windows.Forms.Button printButton;
private Font printFont;
private StreamReader streamToPrint;
public Form4()
{
// The Windows Forms Designer requires the following call.
InitializeComponent();
}
// The Click event is raised when the user clicks the Print button.
private void printButton_Click(object sender, EventArgs e) …Run Code Online (Sandbox Code Playgroud) 使用PrintDocument边距时遇到问题。
无论我做什么,我打印的所有内容总是有一个边距,这意味着没有任何东西在需要的地方对齐。
这是我用来创建的代码 PrintDocument
public void Print()
{
PrintDocument printDocument = new PrintDocument();
printDocument.DefaultPageSettings.PaperSize = new PaperSize("A5",583,827);
printDocument.OriginAtMargins = true;
printDocument.DefaultPageSettings.Margins.Top = 0;
printDocument.DefaultPageSettings.Margins.Left = 0;
printDocument.DefaultPageSettings.Margins.Right = 0;
printDocument.DefaultPageSettings.Margins.Bottom = 0;
if (!string.IsNullOrWhiteSpace(PrinterName))
{
printDocument.PrinterSettings.PrinterName = PrinterName;
}
printDocument.PrintController = new StandardPrintController();
printDocument.PrintPage += On_PrintPage;
printDocument.Print();
}
Run Code Online (Sandbox Code Playgroud)
该On_PrintPage方法具有对e.Graphics.Draw...方法的各种调用。
我怎样才能让我在 0,0 打印的东西打印在页面的左上角。我知道如果打印机无法打印到页面边缘那么远,它将是空白的,但是它应该这样做而不是在页面左上角打印 0,0。
我真的迷路了
在对 UWP 中的打印进行了一些调查之后,我强调了:
这三点使我们能够打印 PDF,但我们在这里有一个问题:
幸运的是,PdfDocument允许您在光栅化过程中提高输出分辨率,但是...
所以我创建了一个示例,您可以使用https://github.com/VitaliyPusan/UwpPrinting
例如,Microsoft Edge 可以以非常好的质量打印 PDF,并且它可以快速完成并且不会消耗额外的内存,但我不知道如何做同样的事情。
有谁知道在 UWP 中打印 PDF 的更好方法?
我的要求是我需要打印发票,它可能包含10行或者可能包含20行.每件东西都应该在一张发票里.
例如,如果您去任何超市,如果您购买3件物品,您可能会收到小额账单.如果您购买30件商品,您可能会收到大笔账单.我想在我的vb.NET应用程序中实现相同的功能.
我确实需要根据账单的性质通过程序增加打印机页面长度.
我正在使用点阵打印机和图形模式打印.
我尝试过的:
截至目前,我已经创建了文本文件,并使用命令行打印使用以下命令打印它
Type Printfile.txt > prn
Run Code Online (Sandbox Code Playgroud)
但是,问题是我无法使用不同的字体,重量或大小来格式化我的文本文件,因为我将其写为文本文件(记事本).
我正在使用streamwriter从VB.NET写入文件,到目前为止我正在尝试在文本文件中格式化它.
我想将一些单词格式化为粗体或斜体和字体大小变化,但由于我使用文本文件格式化,因此我无法这样做.
以下是格式:
Store Name
Store Address
----------------------------------------
Gift Receipt
Transaction #: 105
Date: 11/10/2009 Time: 6:10:10
Cashier: 2 Register: 5
----------------------------------------
Item Description Quantity
----------------------------------------
567577 xyz 2
687687 abc 4
– – – – –
----------------------------------------
Net Amount : 6
Thank You for shopping
XYZ StoreName
We hope you’ll come back soon!
Run Code Online (Sandbox Code Playgroud)
我的打印机名称是\\abc\First Floor A-Block取名为\ abc\NE04上的第一层A-Block:我应该如何打印它
Private oWord As Word.Application
Dim lobjDoc As Word.Document
Dim strFolder as String
Dim pd As New PrintDocument
Dim strPrintername as String
oWord = CreateObject("Word.Application")
oWord.DisplayAlerts = Word.WdAlertLevel.wdAlertsNone
oWord.ActivePrinter =strPrintername
strFolder="D:\testdoc.prn"
Run Code Online (Sandbox Code Playgroud)
'我在这里给出网络上的打印机名称,但它的名字
\ abc\NE04上的A-Block一楼:
lobjDoc = oWord.Documents.Open(CType(strFolder, Object))
lobjDoc.PageSetup.FirstPageTray = Word.WdPaperTray.wdPrinterAutomaticSheetFeed
lobjDoc.PageSetup.OtherPagesTray = Word.WdPaperTray.wdPrinterAutomaticSheetFeed
lobjDoc.PrintOut(Background:=False, Append:=False, OutputFileName:=strFolder, PrintToFile:=True) 'here its giving error about printer settings
lobjDoc.Close(SaveChanges:=False)
Run Code Online (Sandbox Code Playgroud)
有没有办法通过PrintDocument打印包含所有内容的word文档?
谢谢
我试图使用以下代码获取PointOfSale打印机的打印机状态:
Hashtable properties = new Hashtable();
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win2_Printer");
foreach (ManagementObject obj in searcher.Get()) {
if (obj["name"].ToString() == printerName) {
foreach (PropertyData data in obj.Properties) {
if(data.Name.ToLower() = "printerstatus") {
int printerStatus = Convert.ToInt32(data.Value);
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
问题是,状态是3(空闲)或4(打印),即使拔下插头或纸张已用完.
我已经阅读了很多相同问题的帖子,但还没有找到答案.它是否正确?我怎么检查状态?任何帮助表示赞赏.
我想在C#中使用PrintDocument打印文件.该文件是简单的HTML(我需要它,因为我需要文件中的文本位于页面中的特定位置.)
我的问题是,如何打印文件以便它不会打印HTML本身(标签等),而是打印在Web浏览器中显示的HTML?
我有一个窗口服务,它使用 PrintDocument 类打印带有图像的某些文档。有时,我在打印“传递给系统调用的数据区域太小”时遇到此错误,并且报告上的图像未打印。我一直在寻找原因。这是代码:
public string Print(List<PrintPageInfo> printList, Printer_Settings printerSettings)
{
string result = string.Empty;
try
{
List<PrintPageInfo> sortedPrintList = printList.OrderBy(p => p.SequenceOrder).ThenBy(x => x.SubSequenceOrder).ToList();
lock (_printLocker)
{
foreach (var item in sortedPrintList)
{
streams = item.Streams;
if (streams == null || streams.Count == 0)
throw new Exception("No stream to print.");
using (var printDoc = new PrintDocument())
{
printDoc.PrinterSettings.PrinterName = printerSettings.PrinterName;
//if (printDoc.PrinterSettings.IsValid) throw new Exception("Printer name is invalid.");
PrintController printController = new StandardPrintController();
printDoc.PrintController = printController;
printDoc.DefaultPageSettings.Color = true;
printDoc.DefaultPageSettings.Landscape …Run Code Online (Sandbox Code Playgroud) 将页眉和页脚添加到 .Net PrintDocument 对象的最简单方法是实用的还是在设计时?
具体来说,我正在尝试打印一个 3rd 方网格控件(Infragistics GridEx v4.3),它接受一个 PrintDocument 对象并将其自身绘制到其中。
结果页面只包含网格及其内容 - 但是我想添加一个标题或标题来标识打印的报告,可能还有一个页脚来显示谁打印了它,何时打印,最好是页码和总页数。
我正在使用 VB.Net 2.0。
谢谢你的帮助!