Results 1 to 7 of 7
Thread: Creating PDF file from a String
- 11-16-2009, 06:24 PM #1
Member
- Join Date
- Nov 2009
- Posts
- 3
- Rep Power
- 0
Creating PDF file from a String
Hi, i have to do this thing, create a PDF file from a source that is a String. I'm using iText libraries but i'm not able to do that. My conversion function receive a String representing the pdf file (and of course is illegible if i try to print it). I now that is weird (have a string with the content of the pdf inside) but i have no control to the input parameter. I've tried to create the file with the object PdfReader() (this is the code)
InputStream is = new ByteArrayInputStream(myString.getBytes(encoding));
PdfReader reader = new PdfReader(is);
and then write with the PdfWriter but the result is a file illegible (but not empty).
Any idea?
- 11-16-2009, 06:47 PM #2
you have to do it programatically ?
- 11-16-2009, 06:48 PM #3
if you know how to tag the file to make it pdf read the file parse it tag it and save it as a pdf
- 11-16-2009, 06:49 PM #4
open some pdfs in your note pad
- 11-16-2009, 06:59 PM #5
Member
- Join Date
- Nov 2009
- Posts
- 3
- Rep Power
- 0
mmm i don't know what you mean, this is the part of the code which write the file:
InputStream is = new ByteArrayInputStream(myString.getBytes(encoding));
PdfReader reader = new PdfReader(is);
FileOutputStream fos = new FileOutputStream("outfile.pdf");
PdfWriter writer = PdfWriter.getInstance(document, fos);
document.open();
PdfContentByte cb = writer.getDirectContent();
document.newPage();
PdfImportedPage page = null;
page = writer.getImportedPage(reader, 1);
cb.addTemplate(page, 0, 0);
fos.flush();
document.close();
fos.close();
- 11-16-2009, 11:28 PM #6
PDF Reader
why are you using pdf reader when you are reading a text file?
- 11-16-2009, 11:38 PM #7
Member
- Join Date
- Nov 2009
- Posts
- 3
- Rep Power
- 0
Similar Threads
-
Help with creating a variable from a character in string
By Mayur in forum New To JavaReplies: 7Last Post: 10-12-2009, 11:16 PM -
Creating Array of Characters From a String
By ngc0202 in forum New To JavaReplies: 6Last Post: 07-30-2009, 07:30 AM -
Creating jar file
By Heather in forum Advanced JavaReplies: 4Last Post: 02-11-2009, 09:58 AM -
Creating objects based on a String value
By lvh in forum New To JavaReplies: 4Last Post: 04-30-2008, 02:00 PM -
creating .ear file
By psn in forum Enterprise JavaBeans (EJB)Replies: 1Last Post: 01-06-2008, 05:01 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks