Comments (2)
What you want to do has nothing to do with this Graphics2D adapter. You "just" want to resize an existing page.
More something like this
public void scale() throws IOException {
PDDocument document = PDDocument.load(pdf);
PDPage page = document.getPage(0);
PDPageContentStream contentStreamBefore = new PDPageContentStream(document, page, AppendMode.Prepend, true);
Matrix matrix = new Matrix();
float xScale = PDRectangle.A4.getWidth() / page.getMediaBox().getWidth();
float yScale = PDRectangle.A4.getHeight() / page.getMediaBox().getHeight();
matrix.scale(xScale, yScale);
contentStreamBefore.transform(matrix);
contentStreamBefore.close();
document.save(pdf);
document.close();
}
This will add a transform to the whole page by adding an additional content stream with the transform matrix before the existing content.
I did not test this, but should work. (Maybe you need to invert xScale and yScale, as said did not test, so you may need to do a matrix.scale(1/xScale,1/yScale)
).
This question is something for the PDFBox user mailing list or StackOverflow, as it's not related to this project.
from pdfbox-graphics2d.
Thank you, I thought I could be related to this project but no
from pdfbox-graphics2d.
Related Issues (20)
- fontRenderingContext is not good for vector drawing HOT 2
- Adding jaxb-api in the pom of extended-tests HOT 6
- Adding test scope to outer dependencies in the pom of extended-tests HOT 1
- PdfBoxGraphics2DFontTextDrawer.getFontMetrics always floors the width HOT 3
- stop-opacity on linearGradient stops are not rendered HOT 3
- Document how to reuse / share images inside a document across different Graphics2D
- Correctly support embedding the same image with different KEY_INTERPOLATION values. HOT 1
- mapColor parameters in RGBtoCMYKColorMapper HOT 1
- What is a good way to handle "Page N of M" drawing? HOT 2
- TestPPTXRendering.testPPTXRendering failing with libapache-poi-java from Debian 12 HOT 2
- RadialGradientPaint incorrect focal point location and transition direction HOT 1
- drawIssue with incorrect argument HOT 1
- drawRect does not properly close rectangle HOT 2
- String rotation HOT 3
- Exception in RadialGradientPaint HOT 4
- System.err in PdfBoxGraphics2DFontTextDrawer HOT 8
- Draw Attributed text only supports Font, while Family/Weight/Posture is an alternate way. HOT 4
- add pdfbox 3.0.0 support HOT 3
- InternalDeprecatedCOSCloner causing JPMS module issues HOT 3
- Reuse PDFCloneUtilities.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pdfbox-graphics2d.