Allows to specify page properties for an output PDF document: page size, orientation and page margins.

Namespace:  SautinSoft
Assembly:  UseOffice (in UseOffice.dll) Version: 4.3.12.15

Syntax

      
 C#  Visual Basic 
public UseOffice..::.CPageStyle PageStyle { get; set; }
Public Property PageStyle As UseOffice..::.CPageStyle

Remarks

Allows to set page size using the property PageSize



Allows to set page orientation using the property PageOrientation



Allows to set page margins size using properties: PageMarginLeft, PageMarginTop, PageMarginRight and PageMarginBottom



Examples

CopyHow to set a custom page size for a resulted PDF file in C#
using System;
using System.IO;
using System.Collections;
using SautinSoft;

namespace Sample
{
    class Test
    {

        static void Main(string[] args)
        {

            // Convert DOC file to PDF file and specify a custom page size
            // If you need more information about UseOffice .Net email us at:
            // support[at]sautinsoft.com        


            SautinSoft.UseOffice u = new SautinSoft.UseOffice();

            // Path to any local file
            string inFile = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(),@"..\..\..\..\..\..\Testing files\DOC.doc"));
            // Path to output resulted file
            string outFile = Path.ChangeExtension(inFile, ".pdf");

            //Prepare UseOffice .Net, loads MS Word in memory
            int ret = u.InitWord();            

            // Return values:
            // 0 - Loading successfully
            // 1 - Can't load MS Word� library in memory 
            if (ret==1)
                return;

            // Specify A3 page size
            u.PageStyle.PageSize.A3();
            // Set 30 mm as left margin
            u.PageStyle.PageMarginLeft.mm(30f);

            // Converting ...
            ret = u.ConvertFile(inFile, outFile, SautinSoft.UseOffice.eDirection.DOC_to_PDF);

            // Release MS Word from memory
            u.CloseWord();

            // 0 - Converting successfully
            // 1 - Can't open input file. Check that you are using full local path to input file, URL and relative path are not supported
            // 2 - Can't create output file. Please check that you have permissions to write by this path or probably this path already used by another application
            // 3 - Converting failed, please contact with our Support Team
            // 4 - MS Office isn't installed. The component requires that any of these versions of MS Office should be installed: 2000, XP, 2003, 2007 or 2010
            if(ret==0 )
            {
                //Show produced file
                System.Diagnostics.Process.Start(outFile);
            }        
        }
    }
}
CopyHow to set a custom page size for a resulted PDF file in VB.Net
Imports System
Imports System.IO
Imports System.Text
Imports System.Collections


Module Module1
    Sub Main()
        ' Convert DOC file to PDF file and specify a custom page size
        ' If you need more information about UseOffice .Net email us at:
        ' support[at]sautinsoft.com        



        Dim u As New SautinSoft.UseOffice()

        ' Path to any local file
        Dim inFile As String = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), "..\..\..\..\..\Testing files\DOC.doc"))
        ' Path to output resulted file
        Dim outFile As String = Path.ChangeExtension(inFile, ".pdf")

        'Prepare UseOffice .Net, loads MS Word in memory
        Dim ret As Integer = u.InitWord()

        ' Return values:
        ' 0 - Loading successfully
        ' 1 - Can't load MS Word� library in memory 
        If ret = 1 Then
            Return
        End If

        ' Specify A3 page size
        u.PageStyle.PageSize.A3()
        ' Set 30 mm as left margin
        u.PageStyle.PageMarginLeft.mm(30.0F)

        ' Converting ...
        ret = u.ConvertFile(inFile, outFile, SautinSoft.UseOffice.eDirection.DOC_to_PDF)

        ' Release MS Word from memory
        u.CloseWord()

        ' 0 - Converting successfully
        ' 1 - Can't open input file. Check that you are using full local path to input file, URL and relative path are not supported
        ' 2 - Can't create output file. Please check that you have permissions to write by this path or probably this path already used by another application
        ' 3 - Converting failed, please contact with our Support Team
        ' 4 - MS Office isn't installed. The component requires that any of these versions of MS Office should be installed: 2000, XP, 2003, 2007 or 2010
        If ret = 0 Then
            'Show produced file
            System.Diagnostics.Process.Start(outFile)
        End If
    End Sub
End Module

See Also