1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package com.xpn.xwiki.pdf.api

File PdfExport.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart0.png
83% of files have more coverage

Code metrics

0
4
3
2
115
31
3
0.75
1.33
1.5
1

Classes

Class Line # Actions
PdfExport 33 0 - 0 0
-1.0 -
PdfExport.ExportType 36 4 0% 3 7
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package com.xpn.xwiki.pdf.api;
21   
22    import java.io.OutputStream;
23   
24    import com.xpn.xwiki.XWikiContext;
25    import com.xpn.xwiki.XWikiException;
26    import com.xpn.xwiki.doc.XWikiDocument;
27   
28    /**
29    * PDF Exporter, converts a wiki {@link XWikiDocument Document} into PDF.
30    *
31    * @version $Id: 01bf2263a9d0da1c2813faa06dd8c1fe569c4582 $
32    */
 
33    public interface PdfExport
34    {
35    /** Describes export types. */
 
36    class ExportType
37    {
38    /** Export type: PDF. */
39    public static final ExportType PDF = new ExportType("application/pdf", "pdf");
40   
41    /** Export type: RTF. */
42    public static final ExportType RTF = new ExportType("application/rtf", "rtf");
43   
44    /** The MIME type corresponding to this export type. */
45    private final String mimeType;
46   
47    /** The file extension corresponding to this export type. */
48    private final String extension;
49   
50    /**
51    * Constructor, specifying the target MIME type and file extension.
52    *
53    * @param mimeType the standard MIME type for this export type
54    * @param extension the filename extension for this export type
55    */
 
56  0 toggle public ExportType(String mimeType, String extension)
57    {
58  0 this.mimeType = mimeType;
59  0 this.extension = extension;
60    }
61   
62    /**
63    * @return the export content type
64    */
 
65  0 toggle public String getMimeType()
66    {
67  0 return mimeType;
68    }
69   
70    /**
71    * @return the filename extension corresponding to this export type
72    */
 
73  0 toggle public String getExtension()
74    {
75  0 return extension;
76    }
77    }
78   
79    /**
80    * Export a wiki Document into PDF. See
81    * {@link PdfExport#export(XWikiDocument, OutputStream, ExportType, XWikiContext)} for more details about the
82    * conversion process.
83    *
84    * @param doc the document to export
85    * @param out where to write the resulting document
86    * @param context the current request context
87    * @throws XWikiException if the conversion fails for any reason
88    * @see PdfExport#export(XWikiDocument, OutputStream, ExportType, XWikiContext)
89    */
90    void exportToPDF(XWikiDocument doc, OutputStream out, XWikiContext context) throws XWikiException;
91   
92    /**
93    * Export a wiki Document into PDF or RTF. The content of the document is rendered into HTML using the
94    * {@code pdf.vm} template, the resulting HTML is cleaned up into valid XHTML, and custom CSS is applied to it. The
95    * XHTML document is transformed into an XSL-FO document, which is finally processed using Apache FOP.
96    *
97    * @param doc the document to export
98    * @param out where to write the resulting document
99    * @param type the type of the output: PDF or RTF
100    * @param context the current request context
101    * @throws XWikiException if the conversion fails for any reason
102    */
103    void export(XWikiDocument doc, OutputStream out, ExportType type, XWikiContext context) throws XWikiException;
104   
105    /**
106    * Convert an HTML document to PDF. The HTML is cleaned up, and CSS style is applied to it.
107    *
108    * @param html the source document to transform
109    * @param out where to write the resulting document
110    * @param type the type of the output: PDF or RTF
111    * @param context the current request context
112    * @throws XWikiException if the conversion fails for any reason
113    */
114    void exportHtml(String html, OutputStream out, ExportType type, XWikiContext context) throws XWikiException;
115    }