views:

21

answers:

0

I want to print a short receipt in receipt printer, however, i print a whole long web page size.

I refer to the method searched in google and make a dll and register. However, get a automation error can not create object.

THen i regsvr32 scrrun.dll and set allow intialize not safe activex control in internet explorer

it still get the same error. Big brothers, how to do?

\WINDOWS\Microsoft.NET\Framework\v2.0.xxxxx csc /t:library AClass.cs regasm AClass.dll /tlb /codebase

using System.Runtime.InteropServices;

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Drawing.Printing;

namespace ANamespace
{
  public interface ASignatures
  {
    void FName();
  }

  [ClassInterface(ClassInterfaceType.AutoDual)]
  public class AClass :ASignatures
  {
    PrintDocument PD = new PrintDocument();
    PrintPreviewDialog PPD = new PrintPreviewDialog();
    public void FName()
    {
    PD.DefaultPageSettings.PaperSize = new PaperSize("Custom", 80, 350);
    PD.PrinterSettings.DefaultPageSettings.PaperSize = PD.DefaultPageSettings.PaperSize;
    //PD.PrintPage += new PrintPageEventHandler(PD_PrintPage);
    PPD.Document = PD;
    PPD.ShowDialog();
    }
  }
}

<script type="text/javascript">
        function hello()
        {
            var x = new ActiveXObject("ANamespace.AClass");
            x.FName();
        }
        function changescreensize(w,h)
        {
            window.resizeTo(w,h);
        }
       </script>
</head>
<body onload="hello()">