Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Rectangle pageSize = new Rectangle(2780, 2525);
- Document pdfDocument = new Document(pageSize);
- String pdfFilePath = outputFile;
- try
- {
- FileOutputStream fileOutputStream = new FileOutputStream(pdfFilePath);
- PdfWriter writer = null;
- writer = PdfWriter.getInstance(pdfDocument, fileOutputStream);
- writer.open();
- pdfDocument.open();
- /**
- * Proceed if the file given is a picture file
- */
- if (isPictureFile)
- {
- pdfDocument.add(com.lowagie.text.Image.getInstance(inputFile));
- }
- /**
- * Proceed if the file given is (.txt,.html,.doc etc)
- */
- else
- {
- File file = new File(inputFile);
- pdfDocument.add(new Paragraph(org.apache.commons.io.FileUtils.readFileToString(file)));
- }
- pdfDocument.close();
- writer.close();
- }
- catch (Exception exception)
- {
- System.out.println("Document Exception!" + exception);
- }
- PDFConversion pdfConversion = new PDFConversion();
- //pdfConversion.createPdf("C:/shunmuga/tajmahal.jpg", "C:/shunmuga/tajmahal.pdf", true);
- pdfConversion.createPdf("a.html","sample.pdf", false);
- }
Add Comment
Please, Sign In to add comment