print multiple pages from a word document on one page

March3April4

Printing one page of the document in one paper works fine, but my intention is to print four pages in a single A4 paper. If I change the printZoomColumn, and printZoomRow parameter of the printout method, It prints out a blank page.(although the pages matches. I printed out a document of 5 pages, and with the above parameters, it prints out 2 blank pages.)

I use office 2007, and Visual Studio 2012.

My code here is,

public void test5()
{
    try
    {
        // Declaring the object variables we will need later
        object varFileName = filePath;
        object varFalseValue = false;
        object varTrueValue = true;
        object varMissing = Type.Missing;
        object False = false;
        // Create a reference to Microsoft Word application
        Microsoft.Office.Interop.Word.Application varWord =
            new Microsoft.Office.Interop.Word.Application();
        // Creates a reference to a Word document
        varWord.Visible = false;

        Microsoft.Office.Interop.Word.Document varDoc =
            varWord.Documents.Open(ref varFileName, ref varMissing,
               true,
               ref varMissing, ref varMissing, ref varMissing, ref varMissing,
               ref varMissing, ref varMissing, ref varMissing,
               ref varMissing, varFalseValue, ref varMissing, ref varMissing,
               ref varMissing, ref varMissing);
        varDoc.Activate();
        object copies = "1";
        object pages = "";
        object range = Microsoft.Office.Interop.Word.WdPrintOutRange.wdPrintAllDocument;
        object items = Microsoft.Office.Interop.Word.WdPrintOutItem.wdPrintDocumentContent;
        object pageType = Microsoft.Office.Interop.Word.WdPrintOutPages.wdPrintAllPages;
        object oTrue = true;
        object oFalse = false;
        object row = "2";

        varDoc.PrintOut(ref oTrue, ref varFalseValue, ref range,
                ref varMissing, ref varMissing, ref varMissing,
                ref items, ref copies, ref pages, ref pageType,
                ref varFalseValue, ref oTrue, ref varMissing,
                ref varMissing, ref row, ref row, ref varMissing,
                ref varMissing);
        }
    catch (Exception varE)
    {
        MessageBox.Show("Error:\n" + varE.Message, "Error message");
    }
}

On the above source, changing the printout like this works.

varDoc.PrintOut(ref oTrue, ref varFalseValue, ref range,
                    ref varMissing, ref varMissing, ref varMissing,
                    ref items, ref copies, ref pages, ref pageType,
                    ref varFalseValue, ref oTrue, ref varMissing,
                    ref varMissing, ref varMissing, ref vaMissing, ref varMissing,
                    ref varMissing);

But, this is not my intention. I want to print four pages inside the document in a single A4 paper. Is there some concept I'm missing?

BunkerMentality

I can't test this with Office 2007 as I only have 2010 installed here but even in the 2007 interop most (if not all) parameters are optional and if you're using VS2012 the c# should understand optional parameters

document.PrintOut(Background: true, PrintZoomRow: 2, PrintZoomColumn: 2);

So just supply the parameters you actually care about. I think you have to provide the PrintZoomColumn parameter as well for Multiple Pages per Sheet to work, from MSDN:

PrintZoomColumn Optional Variant The number of pages you want Word to fit horizontally on one page. Can be 1, 2, 3, or 4. Use with the PrintZoomRow argument to print multiple pages on a single sheet.

PrintZoomRow Optional Variant The number of pages you want Word to fit vertically on one page. Can be 1, 2, or 4. Use with the PrintZoomColumn argument to print multiple pages on a single sheet.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I make Word print a one-page document multiple times on one single sheet?

From Dev

How to print multiple pages per side with one(right) page blank?

From Dev

How can I print one page enlarged to multiple pages?

From Dev

Copy specific pages from one word document to another word document using C#

From Dev

Is there a way to print multiple worksheets into one document, with correct page numbers?

From Dev

How do I print 4 impressions of a one page document onto a single page in Word?

From Dev

Multiple pages in one html page

From Dev

Print multiple pages from TextBox

From Dev

Print multiple images on one page

From Dev

Crystal Report multiple pages on one page

From Dev

Get pages of word document

From Dev

number of pages in word document

From Dev

How can I print a PDF document on multiple pages?

From Dev

Print from Word to plotter at largest page size

From Dev

R: print multiple types of plots on one page

From Dev

How to print multiple copies of a WORD document in normal order

From Dev

Can't get the pages count from a word document with OpenXml

From Dev

Print range - print from page x until end of document

From Dev

PyQt print multiple pages to PDF only get last page

From Dev

CSS print a custom sized page margin when the content is on multiple pages

From Dev

How do I print a large page on multiple smaller pages?

From Dev

PyQt print multiple pages to PDF only get last page

From Dev

How to print in C# html document in ONE page

From Dev

How to print in C# html document in ONE page

From Dev

Print multiple datagridview pages

From Dev

Print multiple datagridview pages

From Dev

how can we call multiple php pages in one php page?

From Dev

How to combine multiple xaml pages in one xaml page?

From Dev

Print counts from multiple tables in one SQL

Related Related

  1. 1

    How can I make Word print a one-page document multiple times on one single sheet?

  2. 2

    How to print multiple pages per side with one(right) page blank?

  3. 3

    How can I print one page enlarged to multiple pages?

  4. 4

    Copy specific pages from one word document to another word document using C#

  5. 5

    Is there a way to print multiple worksheets into one document, with correct page numbers?

  6. 6

    How do I print 4 impressions of a one page document onto a single page in Word?

  7. 7

    Multiple pages in one html page

  8. 8

    Print multiple pages from TextBox

  9. 9

    Print multiple images on one page

  10. 10

    Crystal Report multiple pages on one page

  11. 11

    Get pages of word document

  12. 12

    number of pages in word document

  13. 13

    How can I print a PDF document on multiple pages?

  14. 14

    Print from Word to plotter at largest page size

  15. 15

    R: print multiple types of plots on one page

  16. 16

    How to print multiple copies of a WORD document in normal order

  17. 17

    Can't get the pages count from a word document with OpenXml

  18. 18

    Print range - print from page x until end of document

  19. 19

    PyQt print multiple pages to PDF only get last page

  20. 20

    CSS print a custom sized page margin when the content is on multiple pages

  21. 21

    How do I print a large page on multiple smaller pages?

  22. 22

    PyQt print multiple pages to PDF only get last page

  23. 23

    How to print in C# html document in ONE page

  24. 24

    How to print in C# html document in ONE page

  25. 25

    Print multiple datagridview pages

  26. 26

    Print multiple datagridview pages

  27. 27

    how can we call multiple php pages in one php page?

  28. 28

    How to combine multiple xaml pages in one xaml page?

  29. 29

    Print counts from multiple tables in one SQL

HotTag

Archive