Delphi 中如何用代码设置打印机默认纸张的默认纸张

扫一扫体验手机阅读
设置系统默认打印机
<span type="1" blog_id="1346596" userid='
114篇文章,20W+人气,0粉丝
大数据时代的微服务之路
¥51.00435人订阅
前百度高级工程师的架构高可用实战
¥51.00235人订阅
<span type="1" blog_id="1346596" userid='I'm printing to an impact printer, loaded with 8.5 x 8.5 inch paper.
When I print, the printer ejects 11 inches instead of 8.5.
PageMediaSize pageSize = new PageMediaSize(PageMediaSizeName.Unknown, element.Width, element.Height);
PrintDialog dialog = new PrintDialog();
dialog.PrintTicket.PageMediaSize = pageS
Console.WriteLine(dialog.PrintableAreaHeight); // 816, good!
dialog.PrintQueue = myQ
// selected from a combobox
Console.WriteLine(dialog.PrintableAreaHeight); // 1056 :(
dialog.PrintVisual(element, description);
Using "" I've determined that 8.5 inches is 816 pixels, which is the size of my element.Width and element.Height.
I'm setting a new PageMediaSize, but this seems to have no effect, dialog.PrintableAreaHeight is still ends up at 1056 when I set the queue on the dialog.
If I do dialog.ShowDialog(), manually pick my printer, and manually find and change Paper Size in my printer's advanced settings, then dialog.PrintableAreaHeight properly reflects the change.
suggests that I can only set a PageMediaSize supported by my printer. Using the GetPrintCapabilities function on my PrintQueue, I see a list of 10 or so page sizes, none of which are 8.5 x 8.5. This is the same list I see when I go to my printer's advanced settings in windows.
解决方案 Please find the code below, it sets paper size as required
var printerSettings = new PrinterSettings();
var labelPaperSize = new PaperSize { RawKind = (int)PaperKind.A6, Height = 148, Width = 105 };
printerSettings.DefaultPageSettings.PaperSize = labelPaperS
var labelPaperSource = new PaperSource { RawKind = (int)PaperSourceKind.Manual };
printerSettings.DefaultPageSettings.PaperSource = labelPaperS
if (printerSettings.CanDuplex)
printerSettings.Duplex = Duplex.D
本文地址: &
我打印到击打式打印机,满载 8.5×8.5 英寸的纸张。当我打印时,打印机弹出11英寸,而不是8.5。
PageMediaSize的pageSize =新PageMediaSize(PageMediaSizeName.Unknown,element.Width ,element.Height);
PrintDialog类对话框=新PrintDialog类();
dialog.PrintTicket.PageMediaSize = pageSize的;
Console.WriteLine(dialog.PrintableAreaHeight); // 816,好!
dialog.PrintQueue = myQueue中; //从ComboBox
Console.WriteLine(dialog.PrintableAreaHeight)选择; // 1056 :(
dialog.PrintVisual(元素,描述);
使用““我已经确定,8.5英寸是816像素,这是我的 element.Width 和 element.Height 。我设置一个新的 PageMediaSize ,但这似乎没有任何效果, dialog.PrintableAreaHeight 在1056当我设置对话框上的队列仍然结束。
如果我 dialog.ShowDialog(),手工挑我的打印机,然后手动查找并更改纸张大小在我的打印机的高级设置,然后 dialog.PrintableAreaHeight 正确反映的变化。
本页面表明,我只能设置一个 PageMediaSize 以支持我打印机。用 GetPrintCapabilities 函数我的打印队列,我看到10个左右的页面大小,其中没有一个是8.5的列表点?x8.5。这是相同的列表我看到,当我去我的打印机的高级设置中的窗口。
解决方案 请找到下面的代码,它按要求设置纸张尺寸
VAR printerSettings =新printerSettings(); 变种labelPaperSize =新PAPERSIZE {RawKind =(INT)PaperKind.A6,身高= 148,宽度= 105};
printerSettings.DefaultPageSettings.PaperSize = labelPaperS 变种labelPaperSource =新PaperSource {RawKind =(int)的PaperSourceKind.Manual};
printerSettings.DefaultPageSettings.PaperSource = labelPaperS 如果(printerSettings.CanDuplex) { printerSettings.Duplex = Duplex.D }
本文地址: &
扫一扫关注IT屋
微信公众号搜索 “ IT屋 ” ,选择关注
与百万开发者在一起
(window.slotbydup = window.slotbydup || []).push({
id: '5828425',
container: s,
size: '300,250',
display: 'inlay-fix'&>&更改默认打印机delphi
更改默认打印机delphi
上传大小:12KB
一台pc机器上需要连接两个打印机,打印时程序自动切换打印设备
综合评分:4
{%username%}回复{%com_username%}{%time%}\
/*点击出现回复框*/
$(".respond_btn").on("click", function (e) {
$(this).parents(".rightLi").children(".respond_box").show();
e.stopPropagation();
$(".cancel_res").on("click", function (e) {
$(this).parents(".res_b").siblings(".res_area").val("");
$(this).parents(".respond_box").hide();
e.stopPropagation();
/*删除评论*/
$(".del_comment_c").on("click", function (e) {
var id = $(e.target).attr("id");
$.getJSON('/index.php/comment/do_invalid/' + id,
function (data) {
if (data.succ == 1) {
$(e.target).parents(".conLi").remove();
alert(data.msg);
$(".res_btn").click(function (e) {
var parentWrap = $(this).parents(".respond_box"),
q = parentWrap.find(".form1").serializeArray(),
resStr = $.trim(parentWrap.find(".res_area_r").val());
console.log(q);
//var res_area_r = $.trim($(".res_area_r").val());
if (resStr == '') {
$(".res_text").css({color: "red"});
$.post("/index.php/comment/do_comment_reply/", q,
function (data) {
if (data.succ == 1) {
var $target,
evt = e || window.
$target = $(evt.target || evt.srcElement);
var $dd = $target.parents('dd');
var $wrapReply = $dd.find('.respond_box');
console.log($wrapReply);
//var mess = $(".res_area_r").val();
var mess = resS
var str = str.replace(/{%header%}/g, data.header)
.replace(/{%href%}/g, 'http://' + window.location.host + '/user/' + data.username)
.replace(/{%username%}/g, data.username)
.replace(/{%com_username%}/g, data.com_username)
.replace(/{%time%}/g, data.time)
.replace(/{%id%}/g, data.id)
.replace(/{%mess%}/g, mess);
$dd.after(str);
$(".respond_box").hide();
$(".res_area_r").val("");
$(".res_area").val("");
$wrapReply.hide();
alert(data.msg);
}, "json");
/*删除回复*/
$(".rightLi").on("click", '.del_comment_r', function (e) {
var id = $(e.target).attr("id");
$.getJSON('/index.php/comment/do_comment_del/' + id,
function (data) {
if (data.succ == 1) {
$(e.target).parent().parent().parent().parent().parent().remove();
$(e.target).parents('.res_list').remove()
alert(data.msg);
//填充回复
function KeyP(v) {
var parentWrap = $(v).parents(".respond_box");
parentWrap.find(".res_area_r").val($.trim(parentWrap.find(".res_area").val()));
评论共有10条
方法不错,值得学习。谢谢!但是分太高了
此软件对我起到了一定的帮助,,
不错啊,值得学习
VIP会员动态
CSDN下载频道资源及相关规则调整公告V11.10
下载频道用户反馈专区
下载频道积分规则调整V1710.18
spring mvc+mybatis+mysql+maven+bootstrap 整合实现增删查改简单实例.zip
资源所需积分/C币
当前拥有积分
当前拥有C币
输入下载码
为了良好体验,不建议使用迅雷下载
更改默认打印机delphi
会员到期时间:
剩余下载个数:
剩余积分:0
为了良好体验,不建议使用迅雷下载
积分不足!
资源所需积分/C币
当前拥有积分
您可以选择
程序员的必选
绿色安全资源
资源所需积分/C币
当前拥有积分
当前拥有C币
为了良好体验,不建议使用迅雷下载
资源所需积分/C币
当前拥有积分
当前拥有C币
为了良好体验,不建议使用迅雷下载
资源所需积分/C币
当前拥有积分
当前拥有C币
您的积分不足,将扣除 10 C币
为了良好体验,不建议使用迅雷下载
无法举报自己的资源
你当前的下载分为234。
你还不是VIP会员
开通VIP会员权限,免积分下载
你下载资源过于频繁,请输入验证码
您因违反CSDN下载频道规则而被锁定帐户,如有疑问,请联络:!
若举报审核通过,可返还被扣除的积分
被举报人:
举报的资源分:
请选择类型
资源无法下载 ( 404页面、下载失败、资源本身问题)
资源无法使用 (文件损坏、内容缺失、题文不符)
侵犯版权资源 (侵犯公司或个人版权)
虚假资源 (恶意欺诈、刷分资源)
含色情、危害国家安全内容
含广告、木马病毒资源
*详细原因:
更改默认打印机delphiDelphi 动态调整打印机纸张大小_百度文库
您的浏览器Javascript被禁用,需开启后体验完整功能,
享专业文档下载特权
&赠共享文档下载特权
&10W篇文档免费专享
&每天抽奖多种福利
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
Delphi 动态调整打印机纸张大小
&&Delphi 动态调整打印机纸张大小
你可能喜欢procedure SetDefaultPrinter(NewDefPrinter: string);&
&&ResStr: array[0..255] of C
&&StrPCopy(ResStr, NewdefPrinter);
&&WriteProfileString('windows', 'device', ResStr);
&&StrCopy(ResStr, 'windows');
&&SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0, Longint(@ResStr));
参数:NewDefPrinter是具体的打印机名称,可以到控制面板-设备和打印机下查看,例如:Microsoft XPS Document Writer使用代码
SetDefaultPrinter('Microsoft XPS Document Writer');
unit Unit1;
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,Printers, StdC
TForm1 = class(TForm)
Button3: TB
ComboBox1: TComboB
procedure Button3Click(Sender: TObject);
{ Private declarations }
{ Public declarations }
Form1: TForm1;
implementation
{$R *.dfm}
procedure SetDefaultPrinter(NewDefPrinter: string);var
ResStr: array[0..255] of Cbegin
StrPCopy(ResStr, NewdefPrinter);
WriteProfileString('windows', 'device', ResStr);
StrCopy(ResStr, 'windows');
SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0, Longint(@ResStr));
procedure TForm1.Button3Click(Sender: TObject);
ComboBox1.Items:=printer.P
ComboBox1.Text:=IntToStr(SizeOf(ComboBox1.Items));
SetDefaultPrinter('Microsoft XPS Document Writer');
阅读(...) 评论()

我要回帖

更多关于 打印机纸张尺寸设置 的文章

 

随机推荐