none
Control Paper size while Printing a (.rtf) document RRS feed

  • Question

  • Hi,

    I have a .rtf document and i need that document to be printed as my Custom Size(8 inch-width X 6 inch-height).

    Currently I am using the below code.

    public void Print_Doc(string Path) { try { Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application { Visible = false }; Microsoft.Office.Interop.Word.Document doc = new Microsoft.Office.Interop.Word.Document(); // where did you get this file name? // as you mentioned, you open your word document here doc = word.Documents.Open(Path); // in your button click handler, just call PrintOut() function // if doc == null, open the document if (doc == null) { // here i assume fileName has been assigned doc = word.Documents.Open(Path); } doc.PrintOut(); } catch (Exception ee) { MessageBox.Show(ee.Message, "Exception", MessageBoxButton.OK, MessageBoxImage.Error); return; } }

    I am using a dot matrix printer and when give a print although the page size is 6 inches filled with data it rolls out the full paper out.

    I want that the printer to stop rolling out the paper after 6 inches and use it for the next time when i give a print.

    If the data exceeds 6 inches, Remaining data should flow into next paper and also Printer should be able to adjust the paper when an paper is rolled out extra.

    Please suggest me the solution for this.

    Thanks,

    • Moved by CoolDadTx Friday, March 27, 2015 1:58 PM Office related
    Thursday, March 26, 2015 8:44 AM

Answers

  • Hi mIN-MADIN,

    As far as I know, there is a PaperSize Class in MSDN.

    That is exactly what the PaperSize Class is for.

    #PageSettings.PaperSize Property

    https://msdn.microsoft.com/en-us/library/system.drawing.printing.pagesettings.papersize(v=vs.110).aspx

       // Create a PaperSize and specify the custom paper size through the constructor and add to combobox.
                PaperSize pkCustomSize1 = new PaperSize("First custom size", 100, 200);

    Best regards,

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    • Edited by Kristin Xie Friday, March 27, 2015 5:51 AM
    • Marked as answer by mIN-MADIN Monday, April 6, 2015 5:53 AM
    Friday, March 27, 2015 5:50 AM
  • Hi mIN-MADMIN,

    According to the descriptin, you were printing the rtf file via open it by Word applicaiton and you want to set the page layout for the word document.

    As far as I know, we can set the page layout via PageSetup object. The following example sets all the margins for the document named "Sales.doc."

    With Documents("Sales.doc").PageSetup 
     .LeftMargin = InchesToPoints(0.75) 
     .RightMargin = InchesToPoints(0.75) 
     .TopMargin = InchesToPoints(1.5) 
     .BottomMargin = InchesToPoints(1) 
    End With
    

    Also we can set the page layout manually in Word and use Macro Recroder to get the code we wanted.  Keep in mind the recorded macro won't be the best possible code in most cases, but it's does very well for a quick example.

    Hope it is helpful.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by mIN-MADIN Monday, April 6, 2015 5:53 AM
    Thursday, April 2, 2015 3:36 AM
    Moderator

All replies

  • Hi mIN-MADIN,

    As far as I know, there is a PaperSize Class in MSDN.

    That is exactly what the PaperSize Class is for.

    #PageSettings.PaperSize Property

    https://msdn.microsoft.com/en-us/library/system.drawing.printing.pagesettings.papersize(v=vs.110).aspx

       // Create a PaperSize and specify the custom paper size through the constructor and add to combobox.
                PaperSize pkCustomSize1 = new PaperSize("First custom size", 100, 200);

    Best regards,

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    • Edited by Kristin Xie Friday, March 27, 2015 5:51 AM
    • Marked as answer by mIN-MADIN Monday, April 6, 2015 5:53 AM
    Friday, March 27, 2015 5:50 AM
  • Hi mIN-MADMIN,

    According to the descriptin, you were printing the rtf file via open it by Word applicaiton and you want to set the page layout for the word document.

    As far as I know, we can set the page layout via PageSetup object. The following example sets all the margins for the document named "Sales.doc."

    With Documents("Sales.doc").PageSetup 
     .LeftMargin = InchesToPoints(0.75) 
     .RightMargin = InchesToPoints(0.75) 
     .TopMargin = InchesToPoints(1.5) 
     .BottomMargin = InchesToPoints(1) 
    End With
    

    Also we can set the page layout manually in Word and use Macro Recroder to get the code we wanted.  Keep in mind the recorded macro won't be the best possible code in most cases, but it's does very well for a quick example.

    Hope it is helpful.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by mIN-MADIN Monday, April 6, 2015 5:53 AM
    Thursday, April 2, 2015 3:36 AM
    Moderator