Pambala Ответов: 7

печать pdf - файла непосредственно без открытия adobe reader


Всем Привет,

Я написал код для прямой печати PDF-документа. Во время этого ADOBE открывается. Может ли кто-нибудь сказать мне, как распечатать PDF-файл, не открывая adobe?Я нашел несколько статей, но они не работали на меня...Вот мой код

private void SendToDirectPrint(string filename)
        {
            ProcessStartInfo info = new ProcessStartInfo();
            info.Verb = "print";
            info.FileName = filename;
            info.CreateNoWindow = true;

            info.WindowStyle = ProcessWindowStyle.Hidden;

            Process p = new Process();
            p.StartInfo = info;
            p.Start();

            if (p.HasExited == false)
            {
                p.WaitForExit(10000);
            }

            p.WaitForInputIdle();
            if (false == p.CloseMainWindow())
                p.Kill();
        }

7 Ответов

Рейтинг:
2

hegde3santu

Вы можете использовать этот код для aspx

----------------------------------------------------------------------------------

 <script type="text/javascript" language="javascript">

        function fnPrint() {
            var a = window.open('', '', 'left =' + screen.width - 100 + ',top=' + screen.height - 10 + ',width=0,height=0,toolbar=0,scrollbars=0,status=0');
            a.document.write(document.getElementById('receipt').innerHTML);
            a.document.close();
            a.focus();
            //call print
            a.print();
            a.close();

        }
      
    </script>


Рейтинг:
2

hegde3santu

function fnPrint(Quotation_project) {
            // window.print();
            var txtOrg_id = Ext.getCmp('txtOrg_id').getValue();
      var txtQuotation_no = Ext.getCmp('txtQuotation_no').getValue();
      var DtDate = (Ext.Date.format(Ext.getCmp('dtDate').getValue(), 'd/m/Y'));
      var txtAddress = Ext.getCmp('txtAddress').getValue();
      var cmbHeadInvoice=Ext.getCmp('cmbHeadInvoice').getValue();
      var txtFinancial_year = Ext.getCmp('txtFinancial_year').getValue();
      var txtInvoice_number = Ext.getCmp('txtInvoice_number').getValue();
      var txtQuotation_amount = Ext.getCmp('txtQuotation_amount').getValue();
     
      var txtInvoice_amount= Ext.getCmp('txtInvoice_amount').getValue();
      var txtStatus= Ext.getCmp('txtStatus').getValue();
      var txtPending_amount= Ext.getCmp('txtPending_amount').getValue();
      var txtCustomer_name= Ext.getCmp('txtCustomer_name').getValue();
      var txtContact_person= Ext.getCmp('txtContact_person').getValue();
     
      var txtEmail= Ext.getCmp('txtEmail').getValue();
    
    //  alert(Tproduct);
          var htmlMarkup=[
''+
'<html xmlns="http://www.w3.org/1999/xhtml">'+
'<head>'+
''+
'body {'+
'	font: 100%/1.4 Verdana, Arial, Helvetica, sans-serif;'+
'	margin: 0;'+
'	padding: 0;'+	
'}'+
'h1, h2, h3, h4, h5, h6, p {'+
'	margin-top: 0;	'+
'	padding-right: 15px;'+
'	padding-left: 15px;'+ 
'}'+
'.container {'+
'	width: 80%;'+
'	max-width: 1260px;'+
'	min-width: 780px;'+
'	background: #FFF;'+
'	margin: 0 auto;'+
'}'+
'</head>'+
'<body>'+
''+
 ' '+
  '   '+
   '  INVOICE      '+
    ' Solutions Private Limited.                                                   Date : '+DtDate+' '+
    '  #21,  1st Floor, Rajashree Mansion                                                      Invoice No:'+txtInvoice_number+''+
     ' ABC  Nagar'+
      ' Main Road'+
      ' 7th Phase,'+
      'Bangalore  512121'+
      ' Ph:  +91 80 1124554'+
'Delivery  Address:'+
''+txtCustomer_name+''+
''+txtAddress+' '+
''+
'Comments or special  instructions:'+
''+
  ''+
   ''+
    ''+
    ''+
   
    ''+
  ''+
  ''+
    ''+
    ''+
    ''+
    ''+
  ''+
'Quotation NumberProduct NmeQuotation AmountInvoice Amount'+txtQuotation_no+''+Quotation_project+''+txtQuotation_amount+''+txtInvoice_amount+'    '+
   '      '+
    'Make all cheques payable to  Solutions Private Limited.'+
    'If you have any questions  concerning this invoice, contact ['+txtContact_person+' '+txtEmail+']'+
    ' '+
    ' THANK YOU FOR YOUR BUSINESS!'+
    ''+
     ' '+
    ''+
    'For  Solutions Pvt Ltd'+
    'Pad'+
    'Managing Director'+
  ''+
'</body>'+
'</html>'
  ];
            var a = window.open('', '', 'left =' + screen.width + ',top=' + screen.height + ',width=0,height=0,toolbar=0,scrollbars=1,status=0');
  a.document.write(htmlMarkup);
            a.document.close();
            a.focus();
            //call print
            a.print();
}


Рейтинг:
2

Marc Gabrie

Ваш код напечатает pdf-файл на принтере, подключенном к серверу, где находится ваш компьютер. ASP.NET сайт размещен. Это то, чего ты хочешь? Я имею в виду, или вы хотите печатать на клиентском принтере?
Если вы печатаете на серверном принтере, то установите FoxIt Reader вместо использования Adobe Reader. FoxIt не откроется при печати из командной строки.


Pambala

Спасибо.да, я тестировал на FoxIt Reader его работы на нем.но они не хотели идти FoxIt Reader, что проблема. еще раз благодарю вас за ваш ответ.

Рейтинг:
1

hegde3santu

Для Extjs :

-----------------------------------------------------------------------------------
   text: '' + printReceipt_lbl + '',
                 handler: function () {
                     var txthidenAmountToPay = Ext.getCmp('txtAmountToPay').getValue();
                     var Credit = Ext.getCmp('txtCredit').getValue();
                     var OsAmount = Ext.getCmp('txtOsAmount').getValue();
                     var RecNo = TrimString(Ext.getCmp('txtRecNo').getValue());
                     window.open('../Certificates/BillReceipt.aspx?BillNo=' + RecNo + '&AmountToPay=' + txthidenAmountToPay +
                 '&Credit=' + Credit + '&OsAmount=' + OsAmount, 'name', 'height=800,width=700,scrollbars=1');

                 }


Рейтинг:
1

hegde3santu

зарегистрируйтесь, чтобы http://pdfcrowd.com/

protected void img_Click(object sender, ImageClickEventArgs e)
    {
System.Web.HttpResponse Response = System.Web.HttpContext.Current.Response;
     try
       {
        var Date = Request.QueryString["Date"].ToString();
        var Org_name = Request.QueryString["Org_name"].ToString();
        var Org_Address = Request.QueryString["Org_Address"].ToString();
        ------------ 
        ------------


// create an API client instance
            pdfcrowd.Client client = new pdfcrowd.Client("username", "password");
//username & password should be given when registration and there are only 150 //converstion is free

            // convert a web page and write the generated PDF to a memory stream
            MemoryStream Stream = new MemoryStream();

            // string sunil = Request.QueryString["test1"].ToString();
            //  string html = "<head></head><body>My HTML Layout" + Request.QueryString["Date"] + "</body>";
            string html = @"

<head>
----------------
---------------

</head>

</body>
</html>


";
client.convertHtml(html, Stream);



            // set HTTP response headers
            Response.Clear();
            Response.AddHeader("Content-Type", "application/pdf");
            Response.AddHeader("Cache-Control", "max-age=0");
            Response.AddHeader("Accept-Ranges", "none");
            Response.AddHeader("Content-Disposition", "attachment; filename=Sample_Letter.pdf");

            // send the generated PDF
            Stream.WriteTo(Response.OutputStream);
            Stream.Close();
            Response.Flush();
            Response.End();
 }
        catch (pdfcrowd.Error why)
        {
            Response.Write(why.ToString());
        }
    }


Рейтинг:
1

Member 14164997

Для VB .Сеть я нашел вот это:

Private Sub PrintTestPages()
        Dim oProcess As New System.Diagnostics.Process
        With oProcess.StartInfo
            .CreateNoWindow = True
            .WindowStyle = ProcessWindowStyle.Hidden
            .Verb = "print"
            .Arguments = "Actual Size"
            .UseShellExecute = True
            .FileName = "c:\mydocumentfolder\test.pdf"
        End With
        oProcess.Start()
    End Sub


Родом из: [Часто задаваемые вопросы: OD] как распечатать документ, не открывая его?-VBForums[^]