How can I send docx and pdf file to printer?
<p>I have the following code which prints text file from C# to printer its based on the <a href="http://csharphelper.com/blog/2016/06/select-and-print-multiple-files-in-c/" rel="nofollow noreferrer">this</a> article it prints plain text perfect but when I try to print <code>.docx</code> and <code>.pdf</code> file it prints but convert the content to some-kind of encoded characters. How can I fix this to print pdf and doc file?</p>

<pre><code>private void btnPrint_Click(object sender, EventArgs e)
{
    // Select the desired printer. ps.Duplex = Duplex.Simplex; // This works
    pdocFile.PrinterSettings.PrinterName = cboPrinter.Text;
    pdocFile.PrinterSettings.Duplex =  Duplex.Horizontal;
    // Print the checked files.
    foreach (string filename in clbFiles.CheckedItems)
    {
        Console.WriteLine("Printing: " + filename);

        // Get the file's name without the path.
        FileInfo file_into = new FileInfo(filename);
        string short_name = file_into.Name;

        // Set the PrintDocument's name for use by the printer queue.
        pdocFile.DocumentName = short_name;

        // Read the file's contents.
        try
        {
            FileContents = File.ReadAllText(filename).Trim();
        }
        catch (Exception ex)
        {
            MessageBox.Show("Error reading file " + filename +
                    ".\n" + ex.Message);
            return;
        }

        // Print.
        pdocFile.Print();
    }

    MessageBox.Show("Spooled " + clbFiles.CheckedItems.Count +
            " files for printing.");
    }
</code></pre>

<p>//</p>

<pre><code>private string FileContents;

// Print a page of the text file.
private void pdocTextFile_PrintPage(object sender, PrintPageEventArgs e)
{
    // Make a font for printing.
    using (Font font = new Font("Courier New", 10))
    {
        // Make a StringFormat to align text normally.
        using (StringFormat string_format = new StringFormat())
        {
            // See how much of the remaining text will fit.
            SizeF layout_area = new SizeF(e.MarginBounds.Width, e.MarginBounds.Height);
            int chars_fitted, lines_filled;
            e.Graphics.MeasureString(FileContents, font,
            layout_area, string_format,
            out chars_fitted, out lines_filled);

            // Print as much as will fit.
            e.Graphics.DrawString(
            FileContents.Substring(0, chars_fitted),
            font, Brushes.Black, e.MarginBounds,
            string_format);

            // Remove the printed text from the string.
            FileContents = FileContents.Substring(chars_fitted).Trim();
        }
    }

    // See if we are done.
    e.HasMorePages = FileContents.Length &gt; 0;
}
</code></pre>

<p>see Image link below</p>

<p><a href="https://i.stack.imgur.com/cpFVF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cpFVF.png" alt="enter image description here"></a></p>