Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Sun Mar 22, 2020 10:16 am

Is it possible to change the position of the existing page elements (image, text...) in a pdf page?
I mean i have a page with some element, i want to shift everything specifying an offset, but without using margins, because i don't want the white borders. (These element exceed the page)

hakzi9898
 
Posts: 7
Joined: Wed Mar 18, 2020 7:59 pm

Mon Mar 23, 2020 9:18 am

Hello,

Thanks for your inquiry and sorry for the late reply as weekend.
Sorry there is no available way to directly change the position of some elements like image or text in PDF page. But our Spire.PDF provides the following method which allows to change the position of whole content of Pdf page by drawing template in a new PDF page. Please have a try. If there is any question, please feel free to contact us.
Code: Select all
//Load sample PDF
PdfDocument pdf = new PdfDocument();
pdf.LoadFromFile("Sample.pdf");

//Create a new PDF
PdfDocument newPdf = new PdfDocument();

//Define PdfTextLayout
PdfTextLayout layout = new PdfTextLayout();
layout.Layout = PdfLayoutType.OnePage;

foreach (PdfPageBase page in pdf.Pages)
{
    //Add new page
    PdfPageBase newPage = newPdf.Pages.Add(page.Size, new PdfMargins(0, 0));

    //Draw the whole content of original page in new page with offset (100,100)
    page.CreateTemplate().Draw(newPage, new PointF(100,100),layout);
}

//Save the document
newPdf.SaveToFile("result.pdf",FileFormat.PDF);
Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1385
Joined: Tue Sep 27, 2016 1:06 am

Tue Mar 31, 2020 8:38 am

Hi,

Greetings from E-iceblue.
Has your issue been resolved?
Your feedback will be highly appreciated.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1385
Joined: Tue Sep 27, 2016 1:06 am

Return to Spire.PDF