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
-
Method Summary
Modifier and TypeMethodDescriptionGet the author of the document.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.void
renderDocumentFromHtml
(String file, String template) Generate a PDF document in the size A4 from a HTML String.void
Set the author for the document.void
setKeywords
(String keywords) Set hte keywords for the document.void
setSubject
(String subject) Set the document subject.void
Set the document title.void
writeDocument
(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:PdfRenderer
Read a PDF from FILE as PdfReader.- Specified by:
loadDocument
in interfacePdfRenderer
- Parameters:
pdfDocument
- as File- Returns:
- pdf as PdfReader
- Throws:
IOException
-
writeDocument
public void writeDocument(PdfDocument pdf, String destination) throws IOException, FileNotFoundException Description copied from interface:PdfRenderer
Writes a PDF document (PdfReader) to the given destination.- Specified by:
writeDocument
in interfacePdfRenderer
- Parameters:
pdf
- as PdfReaderdestination
- as String- Throws:
IOException
FileNotFoundException
-
removePage
Description copied from interface:PdfRenderer
Remove 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:
removePage
in interfacePdfRenderer
- Parameters:
pdf
- as PdfReaderpages
- as int- Returns:
- pdf as PdfReader
- Throws:
IOException
-
renderDocumentFromHtml
Description copied from interface:PdfRenderer
Generate 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:
renderDocumentFromHtml
in interfacePdfRenderer
- Parameters:
file
- as Stringtemplate
- as String- Throws:
FileNotFoundException
-
setAuthor
Description copied from interface:PdfRenderer
Set the author for the document.- Specified by:
setAuthor
in interfacePdfRenderer
- Parameters:
author
- as String
-
setKeywords
Description copied from interface:PdfRenderer
Set hte keywords for the document.- Specified by:
setKeywords
in interfacePdfRenderer
- Parameters:
keywords
- as String
-
setSubject
Description copied from interface:PdfRenderer
Set the document subject.- Specified by:
setSubject
in interfacePdfRenderer
- Parameters:
subject
- as String
-
setTitle
Description copied from interface:PdfRenderer
Set the document title.- Specified by:
setTitle
in interfacePdfRenderer
- Parameters:
title
- as String
-
getAuthor
Description copied from interface:PdfRenderer
Get the author of the document.- Specified by:
getAuthor
in interfacePdfRenderer
- Returns:
- author as String
-
getKeywords
Description copied from interface:PdfRenderer
Get the document related keywords.- Specified by:
getKeywords
in interfacePdfRenderer
- Returns:
- keywords as String
-
getSubject
Description copied from interface:PdfRenderer
Get the document subject.- Specified by:
getSubject
in interfacePdfRenderer
- Returns:
- subject as String
-
getTitle
Description copied from interface:PdfRenderer
Get the document title.- Specified by:
getTitle
in interfacePdfRenderer
- Returns:
- title as String
-