I did some digging and found that MemoryStream works. I updated my code and
it's no longer going to the filesystem. I'm very impressed with what iText
has been able to handle. Here's the code in case anyone ever is interested.
PdfReader readerMain = new PdfReader(Server.MapPath(formFile));
Document document = new
Document(readerMain.GetPageSizeWithRotation(1));
MemoryStream memoryStream = new MemoryStream();
PdfSmartCopy copy = new PdfSmartCopy(document, memoryStream);
document.Open();
foreach (RequestDetail detail in details)
{
PdfReader readerTemp = new PdfReader(Server.MapPath(formFile));
MemoryStream memoryStreamTemp = new MemoryStream();
PdfStamper stamper = new PdfStamper(readerTemp,
memoryStreamTemp);
AcroFields fields = stamper.AcroFields;
... form updates here ...
// flatten form fields and close document
stamper.FormFlattening = true;
stamper.Close();
PdfReader readerTemp2 = new
PdfReader(memoryStreamTemp.ToArray());
copy.AddPage(copy.GetImportedPage(readerTemp2, 1));
}
document.Close();
byte[] b = memoryStream.ToArray();
Response.Clear();
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Length", b.Length.ToString());
Response.AppendHeader("Content-Disposition",
"attachment;filename=tickets.pdf");
Response.OutputStream.Write(b, 0, b.Length);
Response.OutputStream.Flush();
Response.OutputStream.Close();
Response.End();
sanderson wrote:
>
> Nice, that is exactly what I was looking for. I updated my code and the
> 340 page doc went from 24MB down to about 500K. My only issue now is that
> I am still writing each page to a temp file and I would prefer to handle
> this all in memory. I found some Java examples that used a
> ByteArrayOutputStream for the stamper. Any idea what the corresponding
> procedure would be for C#?
>
> Steve
>
>
> Paulo Soares wrote:
>>
>> Append the page using PdfSmartCopy.
>>
>> Paulo
>>
>>
>>
>
>
--
View this message in context:
http://www.nabble.com/Duplicate-Font-Problem-%28itextsharp%29-tf3728362.html#a10643593
Sent from the iText - General mailing list archive at Nabble.com.
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
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/