PdfFileEditor.ResizeContents

ResizeContents(Stream, Stream, int[], ContentsResizeParameters)

Resizes contents of pages of the document.

public bool ResizeContents(Stream source, Stream destination, int[] pages, 
    ContentsResizeParameters parameters)
ParameterTypeDescription
sourceStreamStream with source document.
destinationStreamStream with the destination document.
pagesInt32[]Array of page indexes.
parametersContentsResizeParametersResize parameters.

Return Value

Returns true if success.

Examples

PdfFileEditor fileEditor = new PdfFileEditor();
Stream src = new Stream("input.pdf", FileMode.Open);
Stream dest = new Stream("output.pdf", FileMode.Create);
PdfFileEditor.ContentsResizeParameters parameters = new PdfFileEditor.ContentsResizeParameters(
    //left margin = 10% of page width
    PdfFileEditor.ContentsResizeValue.Percents(10),
    //new contents width calculated automatically as width - left margin - right margin (100% - 10% - 10% = 80%)
    null,
    //right margin is 10% of page 
    PdfFileEditor.ContentsResizeValue.Percents(10),
    //top margin = 10% of height
    PdfFileEditor.ContentsResizeValue.Percents(10),
    //new contents height is calculated automatically (similar to width)
    null,
    //bottom margin is 10%
    PdfFileEditor.ContentsResizeValue.Percents(10)
       );
fileEditor.ResizeContents(src, dest, new int[] { 1, 2,.3}, parameters);
dest.Close();

See Also


ResizeContents(Stream, Stream, int[], double, double)

Resizes contents of document pages. Shrinks contents of page and adds margins. New size of contents is specified in default space units.

public bool ResizeContents(Stream source, Stream destination, int[] pages, double newWidth, 
    double newHeight)
ParameterTypeDescription
sourceStreamStream which contains source document.
destinationStreamStream where resultant document will be saved.
pagesInt32[]Array of page indexes. If null then all document pages will be processed.
newWidthDoubleNew width of page contents in default space units.
newHeightDoubleNew height of page contents in default space units.

Return Value

True if resize was successful.

Examples

PdfFileEditor fileEditor = new PdfFileEditor();
Stream src = new Stream("input.pdf", FileMode.Open);
Stream dest = new Stream("output.pdf", FileMode.Create);
fileEditor.ResizeContents(src, dest, 
//resize all pages of document
null, 
//new contents width = 200
200, 
//new contents height = 300
300);
// rest area of page will be empty

See Also


ResizeContents(string, string, int[], double, double)

Resizes contents of document pages. Shrinks contents of page and adds margins. New size of contents is specified in default space units.

public bool ResizeContents(string source, string destination, int[] pages, double newWidth, 
    double newHeight)
ParameterTypeDescription
sourceStringPath to source document.
destinationStringPath where resultant document will be saved.
pagesInt32[]Array of page indexes. If null then all document pages will be processed.
newWidthDoubleNew width of page contents in default space units.
newHeightDoubleNew height of page contents in default space units.

Return Value

true if resize was successful.

Examples

PdfFileEditor fileEditor = new PdfFileEditor();
fileEditor.ResizeContents("input.pdf", "output.pdf", 
//resize all pages of document
null, 
//new contents width = 200
200, 
//new contents height = 300
300);
// rest area of page will be empty

See Also


ResizeContents(string, string, int[], ContentsResizeParameters)

Resizes contents of pages in document. If page is shrinked blank margins are added around the page.

public bool ResizeContents(string source, string destination, int[] pages, 
    ContentsResizeParameters parameters)
ParameterTypeDescription
sourceStringSource document path.
destinationStringDestination document path.
pagesInt32[]Array of page indexes (page index starts from 1).
parametersContentsResizeParametersParameters of page resize.

Return Value

true if resize was successful.

Examples

PdfFileEditor fileEditor = new PdfFileEditor();
PdfFileEditor.ContentsResizeParameters parameters = new PdfFileEditor.ContentsResizeParameters(
    //left margin = 10% of page width
    PdfFileEditor.ContentsResizeValue.Percents(10),
    //new contents width calculated automatically as width - left margin - right margin (100% - 10% - 10% = 80%)
    null,
    //right margin is 10% of page 
    PdfFileEditor.ContentsResizeValue.Percents(10),
    //top margin = 10% of height
    PdfFileEditor.ContentsResizeValue.Percents(10),
    //new contents height is calculated automatically (similar to width)
    null,
    //bottom margin is 10%
    PdfFileEditor.ContentsResizeValue.Percents(10)
       );
fileEditor.ResizeContents("input.pdf", "output.pdf", new int[] { 1, 2, 3 }, parameters);

See Also


ResizeContents(Document, int[], ContentsResizeParameters)

Resizes pages of document. Blank margins are added around of shrinked page.

public void ResizeContents(Document source, int[] pages, ContentsResizeParameters parameters)
ParameterTypeDescription
sourceDocumentSource document.
pagesInt32[]List of page indexes.
parametersContentsResizeParametersResize parameters.

Examples

PdfFileEditor fileEditor = new PdfFileEditor();
Document doc = new Document("input.pdf");
PdfFileEditor.ContentsResizeParameters parameters = new PdfFileEditor.ContentsResizeParameters(
    //left margin = 10% of page width
    PdfFileEditor.ContentsResizeValue.Percents(10),
    //new contents width calculated automatically as width - left margin - right margin (100% - 10% - 10% = 80%)
    null,
    //right margin is 10% of page 
    PdfFileEditor.ContentsResizeValue.Percents(10),
    //top margin = 10% of height
    PdfFileEditor.ContentsResizeValue.Percents(10),
    //new contents height is calculated automatically (similar to width)
    null,
    //bottom margin is 10%
    PdfFileEditor.ContentsResizeValue.Percents(10)
       );
fileEditor.ResizeContents(doc, new int[] { 1, 2, 3 }, parameters);
doc.Save("output.pdf");

See Also


ResizeContents(Document, ContentsResizeParameters)

Resizes pages of document. Blank margins are added around of shrinked page.

public void ResizeContents(Document source, ContentsResizeParameters parameters)
ParameterTypeDescription
sourceDocumentSource document.
parametersContentsResizeParametersResize parameters.

Examples

PdfFileEditor fileEditor = new PdfFileEditor();
Document doc = new Document("input.pdf");
PdfFileEditor.ContentsResizeParameters parameters = new PdfFileEditor.ContentsResizeParameters(
    //left margin = 10% of page width
    PdfFileEditor.ContentsResizeValue.Percents(10),
    //new contents width calculated automatically as width - left margin - right margin (100% - 10% - 10% = 80%)
    null,
    //right margin is 10% of page 
    PdfFileEditor.ContentsResizeValue.Percents(10),
    //top margin = 10% of height
    PdfFileEditor.ContentsResizeValue.Percents(10),
    //new contents height is calculated automatically (similar to width)
    null,
    //bottom margin is 10%
    PdfFileEditor.ContentsResizeValue.Percents(10)
       );
fileEditor.ResizeContents(doc, parameters);
doc.Save("output.pdf");

See Also


ResizeContents(string, int[], ContentsResizeParameters, HttpResponse)

Resizes contents of pages in document. If page is shrinked blank margins are added around the page. Result is stored into HttpResponse object.

public bool ResizeContents(string source, int[] pages, ContentsResizeParameters parameters, 
    HttpResponse response)
ParameterTypeDescription
sourceStringPath to source file.
pagesInt32[]Array of pages to be resized.
parametersContentsResizeParametersResize parameters.
responseHttpResponseHttpResponse object where result is saved.

Return Value

True if operation was succeeded.

See Also


ResizeContents(Stream, int[], ContentsResizeParameters, HttpResponse)

Resizes contents of pages in document. If page is shrinked blank margins are added around the page. Result is stored into HttpResponse object.

public bool ResizeContents(Stream source, int[] pages, ContentsResizeParameters parameters, 
    HttpResponse response)
ParameterTypeDescription
sourceStreamStream of source file.
pagesInt32[]Array of pages to be resized.
parametersContentsResizeParametersResize parameters.
responseHttpResponseHttpResponse object where result is saved.

Return Value

True if operation was succeeded.

See Also