Class PDFExportScriptService

  • All Implemented Interfaces:
    org.xwiki.script.service.ScriptService

    @Component
    @Named("export.pdf")
    @Singleton
    @Unstable
    public class PDFExportScriptService
    extends Object
    implements org.xwiki.script.service.ScriptService
    Scripting API to export documents as PDF.
    Since:
    14.4.2, 14.5
    Version:
    $Id: e2c98801eb5f394b71d57a6a836c035c5cd0c49c $
    • Constructor Detail

      • PDFExportScriptService

        public PDFExportScriptService()
    • Method Detail

      • createRequest

        public PDFExportJobRequest createRequest()
        Returns:
        a new PDF export request, initialized based on the current HTTP request
      • execute

        public org.xwiki.job.Job execute​(PDFExportJobRequest request)
        Schedule the execution of the given PDF export request.
        Parameters:
        request - the PDF export request to execute
        Returns:
        the asynchronous background job that has been scheduled to execute the given PDF export request
      • isServerSidePrintingAvailable

        public boolean isServerSidePrintingAvailable()
        You should call this only when server-side printing is requested (either by the PDF export configuration or by the PDF export job request) because the availability check can be expensive: the PDF printer needs to be initialized and it needs to verify that the connection between XWiki and the remote web browser (headless Chrome) used for PDF printing is fine.
        Returns:
        true if server-side printing is available, false otherwise
        Since:
        14.8
      • getConfiguration

        public PDFExportConfiguration getConfiguration()
        Returns:
        the PDF export configuration
        Since:
        14.8
      • isEnabled

        public boolean isEnabled()
        Returns:
        true if the Web browser based PDF export is enabled, false otherwise
        Since:
        14.10
      • getLastError

        public Exception getLastError()
        Get the error generated while performing the previously called action.
        Returns:
        an eventual exception or null if no exception was thrown
      • safe

        protected <T> T safe​(T unsafe)
        Type Parameters:
        T - the type of the object
        Parameters:
        unsafe - the unsafe object
        Returns:
        the safe version of the passed object