All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.pdftools.image2pdf.ShrinkToPage Maven / Gradle / Ivy

Go to download

The Pdftools SDK is a comprehensive development library that lets developers integrate advanced PDF functionalities into in-house applications.

There is a newer version: 1.8.0
Show newest version
/****************************************************************************
 *
 * File:            ShrinkToPage.java
 *
 * Description:     PDFTOOLS ShrinkToPage Class
 *
 * Author:          PDF Tools AG
 * 
 * Copyright:       Copyright (C) 2023 - 2024 PDF Tools AG, Switzerland
 *                  All rights reserved.
 * 
 * Notice:          By downloading and using this artifact, you accept PDF Tools AG's
 *                  [license agreement](https://www.pdf-tools.com/license-agreement/),
 *                  [privacy policy](https://www.pdf-tools.com/privacy-policy/),
 *                  and allow PDF Tools AG to track your usage data.
 *
 ***************************************************************************/

package com.pdftools.image2pdf;

import com.pdftools.sys.*;
import com.pdftools.internal.*;
import java.util.EnumSet;
import java.time.OffsetDateTime;
/**
 * 

The image mapping that places the image onto pages of the specified size

* Place images onto portrait or landscape pages. * If an image is too large to fit on a page, the page may be rotated to better accommodate the image. * Large images are scaled down to fit onto the PDF page size * {@link ShrinkToPage#getPageSize }. */ public class ShrinkToPage extends com.pdftools.image2pdf.ImageMapping { protected ShrinkToPage(long handle) { super(handle); } /** * @hidden */ public static ShrinkToPage createDynamicObject(long handle) { return new ShrinkToPage(handle); } /** * */ public ShrinkToPage() { this(newHelper()); } private static long newHelper() { long handle = newNative(); if (handle == 0) { switch (getLastErrorCode()) { case 0: throw new RuntimeException("An unexpected error occurred"); default: throwLastRuntimeException(); } } return handle; } /** *

The page size (Getter)

*

* All output pages are created with that size. * The default page orientation is portrait, but * if the image fits better, the page is rotated to landscape.

*

* Default value: "A4" (210mm 297mm) *

*/ public com.pdftools.geometry.units.Size getPageSize() { com.pdftools.geometry.units.Size retVal = getPageSizeNative(getHandle()); if (retVal == null) { switch (getLastErrorCode()) { case 0: throw new RuntimeException("An unexpected error occurred"); default: throwLastRuntimeException(); } } return retVal; } /** *

The page size (Setter)

*

* All output pages are created with that size. * The default page orientation is portrait, but * if the image fits better, the page is rotated to landscape.

*

* Default value: "A4" (210mm 297mm) *

* * @throws IllegalArgumentException The argument is smaller than "3pt 3pt" or larger than "14400pt 14400pt". * @throws IllegalArgumentException if {@code value} is {@code null} */ public void setPageSize(com.pdftools.geometry.units.Size value) { if (value == null) throw new IllegalArgumentException("Argument 'value' must not be null.", new NullPointerException("'value'")); boolean retVal = setPageSizeNative(getHandle(), value.getWidthValue(), value.getHeightValue()); if (!retVal) { switch (getLastErrorCode()) { case 0: throw new RuntimeException("An unexpected error occurred"); case 3: throw new IllegalArgumentException(getLastErrorMessage()); default: throwLastRuntimeException(); } } } /** *

The page margin (Getter)

* Default value: 20mm (0.79in) */ public com.pdftools.geometry.units.Margin getPageMargin() { com.pdftools.geometry.units.Margin retVal = getPageMarginNative(getHandle()); if (retVal == null) { switch (getLastErrorCode()) { case 0: throw new RuntimeException("An unexpected error occurred"); default: throwLastRuntimeException(); } } return retVal; } /** *

The page margin (Setter)

* Default value: 20mm (0.79in) * * @throws IllegalArgumentException The argument has negative margin values. * @throws IllegalArgumentException if {@code value} is {@code null} */ public void setPageMargin(com.pdftools.geometry.units.Margin value) { if (value == null) throw new IllegalArgumentException("Argument 'value' must not be null.", new NullPointerException("'value'")); boolean retVal = setPageMarginNative(getHandle(), value.getLeftValue(), value.getBottomValue(), value.getRightValue(), value.getTopValue()); if (!retVal) { switch (getLastErrorCode()) { case 0: throw new RuntimeException("An unexpected error occurred"); case 3: throw new IllegalArgumentException(getLastErrorMessage()); default: throwLastRuntimeException(); } } } private static native long newNative(); private native com.pdftools.geometry.units.Size getPageSizeNative(long handle); private native boolean setPageSizeNative(long handle, double valueWidth, double valueHeight); private native com.pdftools.geometry.units.Margin getPageMarginNative(long handle); private native boolean setPageMarginNative(long handle, double valueLeft, double valueBottom, double valueRight, double valueTop); }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy