Package Components
Class PDFCreator
- java.lang.Object
-
- Components.PDFCreator
-
public final class PDFCreator extends java.lang.Object
Class that is used to create a photo album in the form of a pdf file
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
albumName
private static com.itextpdf.text.Document
document
private static com.itextpdf.text.Font
headerFont
private static com.itextpdf.text.Font
imageFont
private static java.util.List<Photo>
photos
private static com.itextpdf.text.Font
smallFont
-
Constructor Summary
Constructors Modifier Constructor Description private
PDFCreator()
Private constructor to hinder creation of utility class
-
Method Summary
Modifier and Type Method Description private static void
addAllImages()
Adds all the images to the PDF document.private static void
addEmptyLineTo(com.itextpdf.text.Paragraph paragraph, int number)
Add an empty line to the PDF document.private static void
addHeader()
Adds the header to the PDF document.private static void
addImageContainers()
Adds the images to the PDF document.static void
createPDF(java.util.List<Photo> AlbumPhotos, java.lang.String saveLocation, java.lang.String name)
Creates a new pdf document with all the photos, author name, and album name.private static com.itextpdf.text.pdf.PdfPTable
createTable(Photo photo)
Creates a PdfTableprivate static com.itextpdf.text.pdf.PdfPCell
createTextCell(java.lang.String text)
Creates a text cell that is positioned to the left of the tableprivate static void
scaleImage(com.itextpdf.text.Image image)
Scales the images according to the ratio between the height and the width of the image.
-
-
-
Field Detail
-
document
private static com.itextpdf.text.Document document
-
photos
private static java.util.List<Photo> photos
-
albumName
private static java.lang.String albumName
-
smallFont
private static com.itextpdf.text.Font smallFont
-
headerFont
private static com.itextpdf.text.Font headerFont
-
imageFont
private static com.itextpdf.text.Font imageFont
-
-
Method Detail
-
createPDF
public static void createPDF(java.util.List<Photo> AlbumPhotos, java.lang.String saveLocation, java.lang.String name) throws java.io.IOException, com.itextpdf.text.DocumentException
Creates a new pdf document with all the photos, author name, and album name.- Parameters:
AlbumPhotos
- all the photos in the album that is getting made into a PDF.saveLocation
- is where the PDF is going to be saved.name
- is the name of the album.- Throws:
java.io.IOException
com.itextpdf.text.DocumentException
-
addHeader
private static void addHeader() throws com.itextpdf.text.DocumentException
Adds the header to the PDF document.- Throws:
com.itextpdf.text.DocumentException
-
addImageContainers
private static void addImageContainers() throws com.itextpdf.text.DocumentException, java.io.IOException
Adds the images to the PDF document.- Throws:
com.itextpdf.text.DocumentException
java.io.IOException
-
addAllImages
private static void addAllImages() throws com.itextpdf.text.DocumentException, java.io.IOException
Adds all the images to the PDF document.- Throws:
com.itextpdf.text.DocumentException
java.io.IOException
-
createTable
private static com.itextpdf.text.pdf.PdfPTable createTable(Photo photo) throws com.itextpdf.text.DocumentException, java.io.IOException
Creates a PdfTable- Parameters:
photo
- the photo that is being added to the table- Returns:
- the finished table
- Throws:
com.itextpdf.text.DocumentException
java.io.IOException
-
createTextCell
private static com.itextpdf.text.pdf.PdfPCell createTextCell(java.lang.String text)
Creates a text cell that is positioned to the left of the table- Parameters:
text
- the text in the cell- Returns:
- the finished cell
-
scaleImage
private static void scaleImage(com.itextpdf.text.Image image)
Scales the images according to the ratio between the height and the width of the image.- Parameters:
image
- the image that is getting scaled.
-
addEmptyLineTo
private static void addEmptyLineTo(com.itextpdf.text.Paragraph paragraph, int number)
Add an empty line to the PDF document.- Parameters:
paragraph
- the paragraph to insert an empty line into.number
- the number of empty lines desired.
-
-