0

There is any chance to Send PDF file directly to printer without print preview?? I want to grab a pdf file from a folder in my project and send it directly to the printer how can I do it in JS or VB.NET????

Tried that one: Silent print a embedded PDF Didn't work!

Here what I have tried:

      <div class="reportFieldsDiv" runat="server" clientidmode="Static">
            <table style="width: 400px; margin: 10px 0px 0px 10px; border: 1px solid black">
                <tr>
                    <td>
                        <img src="~/Images/Layout/TestBadge.jpg" alt="ID Badge" id="mainImage" align="middle"/>
                    </td>
                </tr>
            </table>
            <div style="border: 0px solid black;padding:5px 0px 0px 280px">


                 <asp:Button ID="Button1" runat="server" Text="Print" Width="140px" OnClientClick="printDocument(pdfDocument)" />

              <embed
                type="application/pdf"
                src="~/UserGuide/temp.pdf"
                id="pdfDocument"
                width="100%"
                height="100%">
            </embed>
            </div>


        </div>

JS:

    function printDocument(documentId) {
        var doc = document.getElementById(documentId);

        //Wait until PDF is ready to print    
        if (typeof doc.print === 'undefined') {
            setTimeout(function () { printDocument(documentId); }, 1000);
        } else {
            doc.print();
        }
    }
Community
  • 1
  • 1
Mark Zukerman
  • 55
  • 1
  • 12
  • The greatest question you'll ever see on here, "What have you tried?" – Trevor Nov 05 '14 at 01:10
  • You'll have more control over printing in C#/VB.NET than you will in JavaScript. You might want to look at de-coupling the act of hitting the Print button from the result of printing a PDF, such as - hitting Print queues a print task to be performed by a Windows Service instead. The 'queuing' part could be a record in a database table, MSMQ, etc. EDIT - although if you mean you want to print a PDF on the *client* machine, this isn't the solution. – sh1rts Nov 05 '14 at 01:34
  • how can I implement that in C#/VB.Net? – Mark Zukerman Nov 05 '14 at 01:38

0 Answers0