Created
August 11, 2013 13:08
-
-
Save desireesantos/6204824 to your computer and use it in GitHub Desktop.
Pdffactory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.trailblazers.freewheelers.model; | |
import com.itextpdf.text.Document; | |
import com.itextpdf.text.DocumentException; | |
import com.itextpdf.text.pdf.PdfWriter; | |
import java.io.FileNotFoundException; | |
import java.io.FileOutputStream; | |
import java.io.OutputStream; | |
public class PdfFactory { | |
public static final String FILE_PATH = "./src/main/webapp/pdf/order"; | |
public static final String PDF = ".pdf"; | |
private PdfWriter pdfWriter; | |
public PdfWriter getPdfWriter() { | |
return pdfWriter; | |
} | |
public void create(Document pdf, ReserveOrder orderId) throws FileNotFoundException, DocumentException { | |
String nameFile = generateFileNameWithTypePDF(orderId.getOrder_id()); | |
pdfWriter = PdfWriter.getInstance(pdf, createOutPutStream(nameFile)); | |
} | |
private OutputStream createOutPutStream(String nameFile) throws FileNotFoundException { | |
return new FileOutputStream(FILE_PATH + nameFile); | |
} | |
private String generateFileNameWithTypePDF(Long orderId) { | |
return orderId + PDF; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment