Rotate page content, but not the page itself

I have a PDF that contains 10 pages. All of the pages are set to portrait orientation to give the user a consistent appearance as they read the document.

Even though all of the pages are displayed in portrait, the content on page 5 is rotated 90 degrees in the source document. It appears sideways in the WebViewer, but that’s what my requirements state should happen.

Part of the document processing (which happens in a Go application) is removing certain elements. To do this, I’m creating a pair of ElementReader and ElementWriter variables and copying element from one onto the other. In the real code, I have some logic that checks for certain criteria and if that criteria is met, I don’t copy the element to the new document. In the code sample below, I took out that logic, because it’s irrelevant to the problem. The code below recreates the issue I’m facing.

func (d Document) removeTags() (err error) {
	w := pdftron.NewElementWriter()
	defer w.Destroy()

	r := pdftron.NewElementReader()
	defer r.Destroy()

	pageIterator := d.doc.GetPageIterator()
	defer pageIterator.Destroy()

	for ; pageIterator.HasNext(); pageIterator.Next() {
		currentPage := pageIterator.Current()

		w.Begin(currentPage, pdftron.ElementWriterE_replacement)

		for el := r.Next(); el.GetMp_elem().Swigcptr() != 0; el = r.Next() {


	return err

The issue that I’m facing is that the content on page 5 in the destination document isn’t rotated 90 degrees like it is in the source document, leaving the right side cut off.

Is there a good way to copy the elements and preserve the formatting from the source? If there isn’t an easy way to do that in a general way (i.e. copy all transformations from the source to the destination), can I rotate all of the elements together?

Thanks in advance,

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:


Have you had a chance to review our Page Manipulation guide here PDFTron Systems Inc. | Documentation