Use aspose. pdf to change the PDF File Content

Source: Internet
Author: User

Source: huide Control Network http://www.evget.com/zh-CN/Info/catalog/18035.html

Aspose. pdf contains a pdffileeditor class resizecontents method that allows you to adjust the page content in the PDF file. The contentsresizeparameters class is used to specify the parameters to be used to adjust the page. You can use the resizecontents method to adjust the specific content of all pages or one page.

C #

//Create PdfFileEditor ObjectPdfFileEditor fileEditor = new PdfFileEditor();//Open PDF DocumentDocument doc = new Document("input.pdf");//Specify Parameter to be used for resizingPdfFileEditor.ContentsResizeParameters parameters = new PdfFileEditor.ContentsResizeParameters(//left margin = 10% of page widthPdfFileEditor.ContentsResizeValue.Percents(10),//new contents width calculated automatically as width - left margin - right margin (100% - 10% - 10% = 80%)null,//right margin is 10% of pagePdfFileEditor.ContentsResizeValue.Percents(10),//top margin = 10% of heightPdfFileEditor.ContentsResizeValue.Percents(10),//new contents height is calculated automatically (similar to width)null,//bottom margin is 10%PdfFileEditor.ContentsResizeValue.Percents(10));//Resize Page ContentsfileEditor.ResizeContents(doc, new int[] { 1, 2, 3 }, parameters);//save document into new location.doc.Save("output.pdf");

VB. NET

'Create PdfFileEditor ObjectDim fileEditor As New PdfFileEditor()'Open PDF DocumentDim doc As New Document("input.pdf")'Specify Parameter to be used for resizing'left margin = 10% of page width'new contents width calculated automatically as width - left margin - right margin (100% - 10% - 10% = 80%)'right margin is 10% of page'top margin = 10% of height'new contents height is calculated automatically (similar to width)'bottom margin is 10%Dim parameters As New PdfFileEditor.ContentsResizeParameters(PdfFileEditor.ContentsResizeValue.Percents(10), Nothing, PdfFileEditor.ContentsResizeValue.Percents(10), PdfFileEditor.ContentsResizeValue.Percents(10), Nothing, PdfFileEditor.ContentsResizeValue.Percents(10))'Resize Page ContentsfileEditor.ResizeContents(doc, New Integer() { 1, 2, 3 }, parameters)'save document into new location.doc.Save("output.pdf")

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.