import java.awt.Desktop;
import java.io.File;
import java.io.IOException;
import sferyx.administration.pdfgenerator.PDFGenerator;
public class FileAttachmentTestPdfGenerator
{
public FileAttachmentTestPdfGenerator()
{
PDFGenerator pdfGenerator = new PDFGenerator();
//Appends some title to the page
pdfGenerator.appendHTMLContentToContentBuffer("
This is a test PDF file with Attachments
");
try
{
//Adds local file attachment to the generated PDF with some description
pdfGenerator.addFileAttachmentToContentBuffer("Sample Report:", new java.net.URL("file:///C:/test/sampleReport.pdf"));
//Adds remote file attachment to the generated PDF with some description
pdfGenerator.addFileAttachmentToContentBuffer(" Sferyx logo:", new java.net.URL("https://sferyx.com/images/logos/fulllogo.jpg"));
}
catch(Throwable thr)
{
thr.printStackTrace();
}
//Generate the PDF
pdfGenerator.closeBufferAndGeneratePDF("c:/test/fileAttachmentsTest.pdf", "A4", "Portrait");
try
{
Desktop.getDesktop().open(new File("c:/test/fileAttachmentsTest.pdf"));
}
catch (IOException e)
{
e.printStackTrace();
}
}
public static void main(String args[])
{
new FileAttachmentTestPdfGenerator();
}
}