I need to rotate the contents of a PDF page by an arbitrary angle and the PDPage.setRotation(int) command is restricted to multiples of 90 degrees. The contents of the page are vector and text and I need to be able to zoom in on the contents later, which means that I cannot convert the page to an image because of the loss of resolution.
相关问题
- Correctly parse PDF paragraphs with Python
- Set BaseUrl of an existing Pdf Document
- How can I get all text from a PDF in Swift?
- Renaming named destinations in PDF files
- Write multiple lines of text in a flow with report
相关文章
- Java PDFBox 向PDF文件中写入图片
- Python Sendgrid send email with PDF attachment fil
- C# MVC website PDF file in stored in byte array, d
- How To Programmatically Enable/Disable 'Displa
- How to reduce PDF file size programmatically in Ja
- Search and replace placeholder text in PDF with Py
- ITextSharp 4.1.6. PDF Table - how to remove whites
- jsPDF justify text
In comments it already has been indicated that to draw some content, e.g. an existing regular portrait or landscape page, at an arbitrary angle onto a new regular portrait or landscape page, one can use the mechanism presented in this answer.
As the code presented there
though, here a quick&dirty solution working for the current regular release 1.8.8 without introducing form xobjects.
This method
applies the given transformation to the given page. To make the use case at hands (to rotate the contents of a PDF page) easier, the transformation is enveloped in translations moving the origin of the coordinate system to the center of the page for the transformation.
The method can be used like this
to rotate the pages of a document counterclockwise by 45° (PI/4, mathematically positive rotation direction).
Please read ISO-32000-1 (this is the ISO standard for PDF), more specifically Table 30 ("Entries in a page object"). It defines the
Rotate
entry like this (literal copy/paste):Whenever an ISO standard uses the word shall, you are confronted a normative rule (as opposed to when the standard uses the word should in which case you're facing a recommendation).
In short: you are asking something that is explicitly forbidden by the PDF specification. Meeting your requirement is impossible in PDF. Your page can have an orientation of 0, 90, 180 or 270 degrees. You will have to rotate the contents on the page instead of rotating the page.