ITextSharp Out of memory exception merging multiple pdf
Since this is a large amount of stuff I'd recommend writing directly to a FileStream
instead of a MemoryStream
. This might be an actual case where an Out of Memory Exception might literally mean "Out of Memory".
Also, as Bruno pointed out, the "smart" part of PdfSmartCopy
unfortunately comes at the cost of memory, too. Switching to PdfCopy
should reduce memory pressure although your final PDF might be larger.
Java iText PdfPTable larger than 6 columns
Suppose that this works (it does work, I know):
PdfPTable table = new PdfPTable(6);
table.addCell("1");
table.addCell("2");
table.addCell("3");
table.addCell("4");
table.addCell("5");
table.addCell("6");
document.add(table);
In this case, a table with a single row and 6 columns will be added.
If you change this snippet like this, no table will be added:
PdfPTable table = new PdfPTable(7);
table.addCell("1");
table.addCell("2");
table.addCell("3");
table.addCell("4");
table.addCell("5");
table.addCell("6");
document.add(table);
This table won't be added, because there is only a single row in it, and incomplete rows aren't rendered.
You have two options, either you add:
table.completeRow();
Or you add:
table.addCell("7");
right before adding the table
to the document
.
There is no reason why you could add a table with 6 columns but not a table with 7 columns. Width isn't an issue: if you don't define an absolute width for the columns, then iText will calculate the exact width of each column automatically.
I don't know if I have a document with a table that has 7 columns, but I do have an example of a table that has 8: see the SimpleTable example and simple_table.pdf.
Related Topics
Explicit Conversion Operator Error When Converting Generic Lists
Creating a SQL Server Table from a C# Datatable
How to Get the Development/Staging/Production Hosting Environment in Configureservices
Wix Service Installer Overrides Service Installer Settings
How to Await a List of Tasks Asynchronously Using Linq
How to Make My Windows Form App Snap to Screen Edges
Main: Not All Code Paths Return a Value
What's the Difference Between Using the Serializable Attribute & Implementing Iserializable
How to Make Observablecollection Thread-Safe
The Name '...' Does Not Exist in the Current Context
What's Wrong with These Parameters
Linq to SQL Where Clause Optional Criteria
Receiving JSON Data Back from Http Request
Practical Usage of Virtual Functions in C#
Adding or Subtracting Color from an Image in a Picturebox Using C#
Embedding a File Explorer Instance in a Windows Forms Application Form
How to Determine the Length (I.E. Duration) of a .Wav File in C#