@Test public void shrinkContentYesBoxes() throws IOException, TaskIOException { try (PDDocument document = PDFParser.parse(SeekableSources .inMemorySeekableSourceFrom(getClass().getClassLoader().getResourceAsStream("pdf/one_page.pdf")))) { PDPage page = document.getPage(0); PDRectangle yesBox = new PDRectangle(0, 0, 200, 400); PDRectangle cropBox = new PDRectangle(0, 0, 400, 800); page.setCropBox(cropBox); page.setArtBox(yesBox); page.setTrimBox(yesBox); page.setBleedBox(yesBox); PdfScaler scaler = new PdfScaler(ScaleType.CONTENT); scaler.scale(document, 0.5); assertEquals(new PDRectangle(0, 0, 595, 842), page.getMediaBox()); assertEquals(cropBox, page.getCropBox()); assertEquals(new PDRectangle(150, 300, 100, 200), page.getArtBox()); assertEquals(new PDRectangle(150, 300, 100, 200), page.getBleedBox()); assertEquals(new PDRectangle(150, 300, 100, 200), page.getTrimBox()); } }
public void scale(PDDocument doc, double scale) throws TaskIOException { scale(doc, doc.getPages(), scale); }
PdfScaler { public void scale(PDDocument doc, double scale) throws TaskIOException { scale(doc, doc.getPages(), scale); } }
PdfScaler { public void scale(PDDocument doc, double scale) throws TaskIOException { scale(doc, doc.getPages(), scale); } PdfScaler(ScaleType type); }
PdfScaler { public void scale(PDDocument doc, double scale) throws TaskIOException { scale(doc, doc.getPages(), scale); } PdfScaler(ScaleType type); void scalePages(PDDocument doc); void scalePages(PDDocument doc, Iterable<PDPage> pages, PDRectangle targetBox); void changePageSize(PDDocument doc, Iterable<PDPage> pages, PDRectangle desiredPageSize); void scale(PDDocument doc, double scale); void scale(PDDocument doc, PDPage page, double scale); void scale(PDDocument doc, Iterable<PDPage> pages, double scale); void changePageSize(PDDocument doc, PDPage page, PDRectangle desiredPageSize); static void margin(PDDocument doc, Iterable<PDPage> pages, Margins margins); }
PdfScaler { public void scale(PDDocument doc, double scale) throws TaskIOException { scale(doc, doc.getPages(), scale); } PdfScaler(ScaleType type); void scalePages(PDDocument doc); void scalePages(PDDocument doc, Iterable<PDPage> pages, PDRectangle targetBox); void changePageSize(PDDocument doc, Iterable<PDPage> pages, PDRectangle desiredPageSize); void scale(PDDocument doc, double scale); void scale(PDDocument doc, PDPage page, double scale); void scale(PDDocument doc, Iterable<PDPage> pages, double scale); void changePageSize(PDDocument doc, PDPage page, PDRectangle desiredPageSize); static void margin(PDDocument doc, Iterable<PDPage> pages, Margins margins);  }