Dear colleagues!

I want to resize pdf page with PDFBox 2.0. How should I do that? Is there
some method which allows this kind of job with versions 2.0 or 1.8?
Example of my code is attached.

Best regards,
Roman.
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;

import java.io.File;
import java.io.IOException;

public class Resizer {
    public static void main(String[] args) throws IOException {

        String src = "path_to_src_file";
        String dst = "path_to_dst_file";
        float sx = 0.5f, sy = 0.5f;

        try (PDDocument document = PDDocument.load(new File(src));
             PDDocument output = new PDDocument()) {
            for (PDPage page : document.getPages()) {
                page.getMatrix().scale(sx, sy); // it
                // I cat not change values return by page.getMatrix().
                // How should I do this?

                // page.setCropBox();
                // Methods like "page.set*Box()" change visual area but do not really affect resizing.
                output.addPage(page);
            }
            output.save(dst);
        }
    }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to