Cool, thanks.
But didn't Bruno say below that: "Most viewer (certainly Adobe Reader) need
the PDF as a file; Adobe Reader doesn't accept a byte stream from memory."
How are you actually "viewing" the PDF in the browser?
Thanks in advance.
-- Jim
From: "Iliadis Yannis" <[EMAIL PROTECTED]>
Reply-To: Post all your questions about iText here
<[EMAIL PROTECTED]>
To: "Post all your questions about iText here"
<[EMAIL PROTECTED]>
Subject: Re: [iText-questions] Reading a PDF via a ByteArrayOutputStream?
Date: Fri, 13 Apr 2007 16:37:05 +0300
To give you a small example:
First I define a static reference to the template (physical file).
static String TEMPLATE_PATH="print/templates/template.pdf";
Later in my code I have a function which adds contents to the pdf.
ByteArrayOutputStream policyAsOutputStream = new
ByteArrayOutputStream();
InputStream
readerStream=getClass().getResourceAsStream(TEMPLATE_PATH);
PdfReader polReader = new PdfReader(readerStream);
PdfStamper polStamp = new PdfStamper(polReader,
policyAsOutputStream);
After that I do all my content manipulation (e.g. setting acrofields with
data, placing tables, list etc.)
And at the end I return the ByteArrayOutputStream which is servered through
the web service to the web client.
return policyAsOutputStream;
2007/4/13, Mork Afur <[EMAIL PROTECTED]>:
Interesting.
It really sounds like the file based approach makes more sense (since the
Adobe plug-in can't handle memory-only baos's).
Iliadis mentioned reading the PDF into a ByteArrayOutputStream. However,
checking around the book (including chapter 17), I didn't find a simple
way
to load an existing file-based PDF into a baos.
The following example files use baos, but, don't seem to load an existing
PDF into one. (probably because it's not useful?)
C:\temp\examples\chapter02\HelloWorldAddMetadata.java
C:\temp\examples\chapter02\HelloWorldCopyStamp.java
C:\temp\examples\chapter02\HelloWorldStampCopy.java
C:\temp\examples\chapter02\HelloWorldStampCopyStamp.java
C:\temp\examples\chapter17\FoobarCourses.java
C:\temp\examples\chapter17\helloworld.jsp
C:\temp\examples\chapter17\OutSimplePdf.java
C:\temp\examples\chapter17\ProgressServlet.java
C:\temp\examples\chapterF\HelloWorldAddMetadata.java
C:\temp\examples\chapterF\HelloWorldXmpMetadata.java
Thanks in advance.
M
>From: "Bruno Lowagie (iText)" <[EMAIL PROTECTED]>
>Reply-To: Post all your questions about iText here
><[EMAIL PROTECTED]>
>To: Post all your questions about iText here
><[EMAIL PROTECTED]>
>Subject: Re: [iText-questions] Reading a PDF via a
ByteArrayOutputStream?
>Date: Fri, 13 Apr 2007 13:43:37 +0200
>
>Strange, I received the answer to this question,
>but not the original question. Anyhow:
>
>Iliadis Yannis wrote:
> > I for myself read a pdf template (physical file) into a
> > ByteArrayOutputStream and pass it to a PdfStamper where I do all the
> > manipulation (in your case a PdfWriter object).
>
>That's an ideal way to do it if you are reusing
>the same template over and over again.
>
> > After that the final pdf (still a ByteArrayOutputStream) is send
through
> > a web service to the clients web browser. From there the adobe reader
> > plug takes over and shows the pdf.
>
>Yep, but remember that the PDF will be stored somewhere
>as a file on the client machine (maybe only temporarily).
>Most viewer (certainly Adobe Reader) need the PDF as a
>file; Adobe Reader doesn't accept a byte stream from memory.
>
> > 2007/4/13, Mork Afur <[EMAIL PROTECTED]
> > <mailto:[EMAIL PROTECTED]>>:
> >
> > In the case where a file-based PDF would have a short life span,
we
>are
> > thinking about just using a ByteArrayOutputStream representation
for
> > creating and viewing the PDF.
> >
> > Is this possible? I'm not sure how we'd "view" the
> > ByteArrayOutputStream.
> >
> > Also, there is only one example (in the 297 java examples with
the
>book)
> > that returns a "baos" object.
>
>In Chapter 2 I explain that you can write to any OutputStream,
>including a ByteArrayOutputStream. Point is: how are you going
>to send those bytes to a Viewer?
>If you really want to keep the documents in memory only,
>you could try writing a PDF to a Ramdisk and let the viewer
>read it from there. I haven't tried this yet. Do people still
>use ramdisk? I feel very old when I use that word...
>
>br,
>Bruno
>
>-------------------------------------------------------------------------
>Take Surveys. Earn Cash. Influence the Future of IT
>Join SourceForge.net's Techsay panel and you'll get the chance to share
>your
>opinions on IT & business topics through brief surveys-and earn cash
>http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>_______________________________________________
>iText-questions mailing list
>[EMAIL PROTECTED]
>https://lists.sourceforge.net/lists/listinfo/itext-questions
>Buy the iText book: http://itext.ugent.be/itext-in-action/
_________________________________________________________________
Get a FREE Web site, company branded e-mail and more from Microsoft Office
Live! http://clk.atdmt.com/MRT/go/mcrssaub0050001411mrt/direct/01/
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share
your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share
your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/
_________________________________________________________________
Cant afford to quit your job? Earn your AS, BS, or MS degree online in 1
year.
http://www.classesusa.com/clickcount.cfm?id=866145&goto=http%3A%2F%2Fwww.classesusa.com%2Ffeaturedschools%2Fonlinedegreesmp%2Fform-dyn1.html%3Fsplovr%3D866143
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/