Package org.europa.together.application
Class OpenPdfRenderer
java.lang.Object
org.europa.together.application.OpenPdfRenderer
- All Implemented Interfaces:
PdfRenderer
Implementation of a simple PDF Renderer.
https://knpcode.com/java-programs/generating-pdf-java-using-openpdf-tutorial/#HelloWorldOpenPDF
https://knpcode.com/java-programs/generating-pdf-java-using-openpdf-tutorial/#HelloWorldOpenPDF
-
Field Summary
Fields inherited from interface org.europa.together.business.PdfRenderer
FEATURE_ID -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGet the author of the document.Return the used paper fromat dimension. the default size is A4 with a margin of 20 millimeter.Get the document related keywords.Get the document subject.getTitle()Get the document title.loadDocument(File pdfDocument) Read a PDF from FILE as PdfReader.removePage(PdfDocument pdf, int... pages) Remove from a given PDF pages.voidrenderDocumentFromHtml(String file, String template) Generate a PDF document in the size A4 from a HTML String.voidSet the author for the document.voidChange the default papersize format fom A4 to a cutom value.
(width / height) size: 21cm 29.7cm; margin: 20mm 20mm;voidsetKeywords(String keywords) Set hte keywords for the document.voidsetSubject(String subject) Set the document subject.voidSet the document title.voidwriteDocument(PdfDocument pdf, String destination) Writes a PDF document (PdfReader) to the given destination.
-
Constructor Details
-
OpenPdfRenderer
public OpenPdfRenderer()
-
-
Method Details
-
loadDocument
Description copied from interface:PdfRendererRead a PDF from FILE as PdfReader.- Specified by:
loadDocumentin interfacePdfRenderer- Parameters:
pdfDocument- as File- Returns:
- pdf as PdfReader
- Throws:
IOException- case of error
-
writeDocument
public void writeDocument(PdfDocument pdf, String destination) throws IOException, FileNotFoundException Description copied from interface:PdfRendererWrites a PDF document (PdfReader) to the given destination.- Specified by:
writeDocumentin interfacePdfRenderer- Parameters:
pdf- as PdfReaderdestination- as String- Throws:
IOException- case of errorFileNotFoundException- case of error
-
removePage
Description copied from interface:PdfRendererRemove from a given PDF pages. Usage:
PdfReader pdf = readDocument(new File(document.pdf)); File newPdf = removePages(pdf, 2, 4, 12);
Removes from the PDF document the pages: 2,4 and 12.- Specified by:
removePagein interfacePdfRenderer- Parameters:
pdf- as PdfReaderpages- as int- Returns:
- pdf as PdfReader
- Throws:
IOException- case of error
-
renderDocumentFromHtml
public void renderDocumentFromHtml(String file, String template) throws FileNotFoundException, IOException Description copied from interface:PdfRendererGenerate a PDF document in the size A4 from a HTML String. The file parameter define the path were the PDF will sored an how the document is named.- Specified by:
renderDocumentFromHtmlin interfacePdfRenderer- Parameters:
file- as Stringtemplate- as String- Throws:
FileNotFoundException- case of errorIOException
-
setAuthor
Description copied from interface:PdfRendererSet the author for the document.- Specified by:
setAuthorin interfacePdfRenderer- Parameters:
author- as String
-
setKeywords
Description copied from interface:PdfRendererSet hte keywords for the document.- Specified by:
setKeywordsin interfacePdfRenderer- Parameters:
keywords- as String
-
setSubject
Description copied from interface:PdfRendererSet the document subject.- Specified by:
setSubjectin interfacePdfRenderer- Parameters:
subject- as String
-
setTitle
Description copied from interface:PdfRendererSet the document title.- Specified by:
setTitlein interfacePdfRenderer- Parameters:
title- as String
-
setFormat
Description copied from interface:PdfRendererChange the default papersize format fom A4 to a cutom value.
(width / height) size: 21cm 29.7cm; margin: 20mm 20mm;- Specified by:
setFormatin interfacePdfRenderer- Parameters:
format- as String
-
getAuthor
Description copied from interface:PdfRendererGet the author of the document.- Specified by:
getAuthorin interfacePdfRenderer- Returns:
- author as String
-
getKeywords
Description copied from interface:PdfRendererGet the document related keywords.- Specified by:
getKeywordsin interfacePdfRenderer- Returns:
- keywords as String
-
getSubject
Description copied from interface:PdfRendererGet the document subject.- Specified by:
getSubjectin interfacePdfRenderer- Returns:
- subject as String
-
getTitle
Description copied from interface:PdfRendererGet the document title.- Specified by:
getTitlein interfacePdfRenderer- Returns:
- title as String
-
getFormat
Description copied from interface:PdfRendererReturn the used paper fromat dimension. the default size is A4 with a margin of 20 millimeter.- Specified by:
getFormatin interfacePdfRenderer- Returns:
- format as String
-