Package Components
Class PDFCreator
- java.lang.Object
-
- Components.PDFCreator
-
public final class PDFCreator extends java.lang.ObjectClass 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.StringalbumNameprivate static com.itextpdf.text.Documentdocumentprivate static com.itextpdf.text.FontheaderFontprivate static com.itextpdf.text.FontimageFontprivate static java.util.List<Photo>photosprivate static com.itextpdf.text.FontsmallFont
-
Constructor Summary
Constructors Modifier Constructor Description privatePDFCreator()Private constructor to hinder creation of utility class
-
Method Summary
Modifier and Type Method Description private static voidaddAllImages()Adds all the images to the PDF document.private static voidaddEmptyLineTo(com.itextpdf.text.Paragraph paragraph, int number)Add an empty line to the PDF document.private static voidaddHeader()Adds the header to the PDF document.private static voidaddImageContainers()Adds the images to the PDF document.static voidcreatePDF(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.PdfPTablecreateTable(Photo photo)Creates a PdfTableprivate static com.itextpdf.text.pdf.PdfPCellcreateTextCell(java.lang.String text)Creates a text cell that is positioned to the left of the tableprivate static voidscaleImage(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.IOExceptioncom.itextpdf.text.DocumentException
-
addHeader
private static void addHeader() throws com.itextpdf.text.DocumentExceptionAdds the header to the PDF document.- Throws:
com.itextpdf.text.DocumentException
-
addImageContainers
private static void addImageContainers() throws com.itextpdf.text.DocumentException, java.io.IOExceptionAdds the images to the PDF document.- Throws:
com.itextpdf.text.DocumentExceptionjava.io.IOException
-
addAllImages
private static void addAllImages() throws com.itextpdf.text.DocumentException, java.io.IOExceptionAdds all the images to the PDF document.- Throws:
com.itextpdf.text.DocumentExceptionjava.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.DocumentExceptionjava.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.
-
-