.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Printing in Landscape

Posted By:      Posted Date: April 14, 2011    Points: 0   Category :Windows Application

Hello Everybody,

I am using following method to print a file programmatically. Is there a way to tell the program to print the file in landscape?

Public Function PrintPDF(ByVal PDFFile As String, ByVal Printer As String, ByVal Timeout As Integer) As Integer

        If PrinterName.Trim.Length = 0 Then
            PrinterName = (New System.Drawing.Printing.PrinterSettings).PrinterName
        End If
        'PrinterName = "a"
        Dim Proc As New System.Diagnostics.Process

        Proc.EnableRaisingEvents = True
        Proc.StartInfo.FileName = PDFFile
        Proc.StartInfo.Arguments = Chr(34) + PrinterName + Chr(34)
        Proc.StartInfo.Verb = "PrintTo"
        Proc.StartInfo.WindowStyle = ProcessWindowStyle.Minimized
        Proc.StartInfo.CreateNoWindow = True
        If Proc.Start() = False Then

View Complete Post

More Related Resource Links

Printing Landscape Report using the Print Control of the ASP.NET Report Viewer

I am using the ASP.NET Report Viewer 2010 web control in remote processing mode connected to a SQL Server Reporting Services 2008 R2 report server in Native Mode. I am viewing the report in IE8 and the print control within the report viewer is available. According to "Printing Reports from a Browser Using the Print Control" at http://msdn.microsoft.com/en-us/library/ms159237.aspx  "The Print dialog box and the default printer settings for width, height, and page orientation are determined by the report definition." In SQL Server Business Intelligence Development Studio I am using the “Report Properties” window accessed from the “Report” menu to set the Orientation to “Landscape”, the paper size to “Letter”, the Width to “11in”, and the Height to “8.5in” in the report definition. When viewing the report using the ASP.NET Report Viewer 2010 in IE8 and exportint to PDF, the report renders correctly in landscape orientation and the size both on screen and printed is as defined in the report definition. However, if I print it directly from the ASP.NET Report Viewer using the Print Control the print preview shows the report correctly in landscape orientation and page size, but the resulting printout is in portrait orientation and skewed or cropped.  If I go into the properti

Issue with landscape printing using PrintVisual


I was playing around with Petzold's PrintWithMargins program from chapter 17 in his book "Applications = Code + Markup". The code is available at http://www.microsoft.com/mspress/companion/0-7356-1957-3/. The problem can be boiled down to having a window with a print button. The Click handler is as follows:

void PrintOnClick(object sender, RoutedEventArgs args)
  PrintDialog dialog = new PrintDialog();

  if (dialog.ShowDialog().GetValueOrDefault())
    DrawingVisual visual = new DrawingVisual();
    DrawingContext context = visual.RenderOpen();

    Pen pen = new Pen(Brushes.Black, 1);

    Rect borderRect = new Rect(96, 96, 
      dialog.PrintableAreaWidth - 2 * 96, 
      dialog.PrintableAreaHeight - 2 * 96);

    context.DrawRectangle(null, pen, borderRect);

    dialog.PrintVisual(visual, Title);

So, it is just drawing a rectangle one inch from the edge of the printable area. I'm printing using Microsoft XPS Document

Printing Landscape oriented reports with SSRS 2008 and SQL Server 2008 R2




I am having issues when I print reports with SSRS 2008. We have an web application that uses the Report Viewer control to preview our Reports in a popup window. The preview page shows the report in the correct orientation and so does any report that has been exported to PDF or Excel file.

The problem arises when we print the report. For some reason any report set to landscape is still being printed in Portrait orientation. The reports have their heights and width properly set, i.e., for portrait reports we have the layout set to 8.5in x 11in and for landscape reports we have the layout set to 11in x 8.5in.

I have done some research and I did not get a conclusive answer, it seems that this happens because of a bug or maybe because how my ReportViewer object in the aspx page is being set.

I would deeply appreciate any extra info you guys can provide.  

Bluetooth Printing Guide using Windows Mobile Pocket Pc

FieldSoftware Products printing products use the Bluetooth "Serial Port Profile" (SPP). Unfortunately, there is no standard method to find your Bluetooth printer and begin printing... each device contains a Bluetooth stack/driver that determines the steps. There are two main stacks currently available... one from Microsoft and one from WIDCOMM/Broadcom. Below are step-by-step instructions for printing with the Microsoft and WIDCOMM stacks. Note that these may change for different versions of the Bluetooth stacks or for different manufacturers. Consult the documentation for your device for specific details on your device.

Identifying your device''s Bluetooth stack: There is no sure steps to identify a Bluetooth stack on a device. Below are steps for identifying current WIDCOMM and Microsoft stacks at the time this page is published. Note that these may not identify earlier or later versions of the same BT stacks.

ASP.net Ajax TabContainer -- Printing All tabs



Can  anyone help me with this?. I want to print all the tabs in ajax tab container. The tab container has around 10 tabs. I dont want to goto each tab and print the page. Instead is there any way by which I can tweek the print.css file to print all the tabs at a single stretch?.  So that I will get all the contents of the tab in single print.  Is there any other way in which I can print all the tabs all together?.

Thanks in Advance...


Printing resource files



I have some resource files for localization and would like to print them. When I try to print them in Visual Studio (with File -> Print...) the button is disabled. Does anyone know how to print them? (Without copying each into word or excel)

Thanks and regards,

Automatic Batch Printing in ReportViewer Remote Mode


Please help me, i have a properly working codes that is capable of the following:

1. Printing of Reports from ReportViewer without using the build-in print ICON in the actual ReportViewer. to view the working for the printing alone please click here.

2. Batch Printing by making a loop and placing a checkbox on the gridview where the needed paramerter (DataKeyNames ID) is retrieved then pass to the ReportViewer

This is my Code

foreach (GridViewRow row in GridView1.Rows)
            CheckBox chk = (CheckBox)row.FindControl("CheckBox2");
            if (chk.Checked)
                ReportViewer1.ServerReport.ReportServerUrl = new Uri("http://TestServer/ReportServer");
                ReportViewer1.ServerReport.ReportPath = @"/Tavern/StudPaymentReport";
                ReportViewer1.ProcessingMode = ProcessingMode.Remote;
                ReportParameter[] rptParams = new ReportParameter[1];

                rptParams[0] = new ReportParameter("ClientID", GridView1.DataKeys[row.RowIndex].Value.ToString());


Printing crystal report from webservice



I am trying to print crystal repot directly from a C# application, which is calling webservice. I am able to display report in crystalreportviewer by passing the webservice call to datasource. However, is there anyway, I can print directly without showing the report?

Alternatively, I was trying return ReportDocument object from webservice, which would solve my problem, but I was unable to return the ReportDocument because of serialization issue. Is it even possible? Thank you


Editor's Note: Healthy Printing


Why we use the paper we do.

Joshua Trupin

MSDN Magazine November 2006

Printing: Preview and Print from Your Windows Forms App with the .NET Printing Namespace


Printing is an integral part of every complete Windows-based application. Providing robust printing capabilities in these applications has often proved to be a tedious chore. Now, printing from Windows Forms with the .NET Framework means you must adopt a document-centric approach, resulting in cleaner and more manageable code. While the System.Windows.Forms namespace provides seamless integration with all the standard print dialogs (such as Print Preview, Page Setup, and Print), the System.Drawing.Printing namespace offers numerous classes for extensibility and customization. These classes, and how they provide access to printing capabilities, are covered here. Other useful techniques, such as printing in the background to allow the user to continue other tasks, is also explained.

Alex Calvo

MSDN Magazine February 2003

Printing MSCHART in my web application


Hello I have a web application with several MSChart and I need print all these chart but I dont know how. In some examples in the internet people using EditCopy() but it dont working for me because I cant found that method.

Need some help  Thanks

While Printing an Infopath Form it Prints lot of Blank Spaces Before RichText Field


I had an infopath form with few rich text field. When i copy some content from somewhere and paste in the richtext Box then while Printing the form I get Lot of Blank Spaces Infront of the rich text box.

I tried creating teh print view too but still i get bunch of empty pages printed before by richtext box control.

Is there a way we can remove those blank spaces.....

I am not able to find out what is going wrong here....

Printing Issue




I have a form with an auto-resizing textbox. There are three views on it (Default, Read-only and Print View). I put text until the textbox limit before it expands. I click "Print View". In the Print View, everything works fine, but when I click "Print Preview", some characters do not appear in the textbox (and when I print, these characters do not appear too).


These images will help to understand.






Printing RichtextBox

I was using the following code to print the contents of a richtextbox:         pd.PrintDocument(((CType(Me.richTextBox.Document, IDocumentPaginatorSource)).DocumentPaginator), "printing as paginator")but it prints in 3 columns. So i tried using this code but it does not print InluneUiContainersDim docWriter As XpsDocumentWriter = PrintQueue.CreateXpsDocumentWriter(ia)     If (docWriter IsNot Nothing And ia IsNot Nothing) Then         Dim paginator As DocumentPaginator = CType(fd, IDocumentPaginatorSource).DocumentPaginator         'Change the PageSize and PagePadding for the document to match the CanvasSize for the printer device.         paginator.PageSize = New Size(ia.MediaSizeWidth, ia.MediaSizeHeight)         Dim pagePadding As Thickness = fd.PagePadding         fd.PagePadding = New Thickness    (Math.Max    (ia.OriginWidth,     pagePadding.Left),     Math.Max    (ia.OriginHeight,     pagePadding.Top),         Math.Max(ia.MediaSizeWidth - (ia.OriginWidth + ia.ExtentWidth), pagePadding.Right), Math.Max(ia.MediaSizeHeight - (ia.OriginHeight + ia.ExtentHeight), pagePadding.Bottom))     fd.ColumnWidth = Double.PositiveInfinity     'Send DocumentPaginator to the printer.     docWriter.Write(paginator) End If Also tried the following but this is completely wrong:        pd.PrintVisual(CType(Me.richTextBox, Visual), "printing as visual")Any ideas?

Printing settings?

Hi all, I want to print an HTML file using webbrowser control in C# and I want to print it in A5 paper size without showing page setup dialog to the user. What can I do? Please help on this. thanks.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend