Skip to content

Trying to print a file which is .pmf file in c# application

Avinash nagabhushanam

Asked Jul 13, 2015, 12:56 AM EDT1 answer
Share
LinkedInX
I am trying to print a file which is .pmf file using print button which should display printer properties as well but after executing the below code I am getting a blank page as a result. Please, anybody can tell me what is wrong with the code shown below. I have added PrintDialog control from Toolbox to the Form in Visual Studio.
TypeScript
	private void btn_Print_Click(object sender, EventArgs e)
        {
	    PrintDialog printDlg = new PrintDialog();
            PrintDocument printDoc = new PrintDocument();
            printDoc.DocumentName = "D:\\Project_Folder\\Soil_Units_PMF\\pmf\\KUM1_1G1b_Soilunits_Profile.pmf";
            printDlg.Document = printDoc;
            printDlg.AllowSelection = true;
            printDlg.AllowSomePages = true;
            //Call ShowDialog
            if (printDlg.ShowDialog() == DialogResult.OK)
            {

                printDoc.Print();

            }
            else
            {
                return;
            }

        }

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    How exactly do you load the PMF file in your C# application?
    If you cannot load it in C#, can you view it in any Windows application with print option?

    Generally, the PMF format is not a commonly known format and the default .NET classes don't recognize it.
    You need to find a way to load the PMF file in .NET, convert it to a known format, and then pass it to the PrintDocument class.
    If you can load the PMF file using a Windows application with print option, then you can use the Virtual Printer features from Leadtools), which captures the print job so that you can save it to any supported format in your code.  You can find more information here.
    0