iTextSharp large table: adding in chunks leaves visible gaps in the table - itext

I have a large table I'm adding to a document. In order to avoid running out of memory, I'm doing this:
if (rowCounter % 100 == 0)
{
document.Add(affidavitsTable);
}
That improved performance, but now, after ever 100 rows, there's a gap in the middle of the table:
I've placed a screenshot here - sorry can't post images yet... :-/
I'm don't really understand what the comments mean here but I'm wondering if it's related.
Any help would be appreciated!
Thanks,
Eliezer

I found the answer. This line was hiding in my code:
affidavitsTable.SpacingBefore = 8;
:-\

Related

DevExpress VerticalGrid in unbound mode with MultiRecordLayout

EDIT: As it turns out, the grid does not support unbound mode in MultiRecordView layout.
I will try to ask this question a different way since my last one was downvoted without comment, so I don't know what the downvoter was objecting to.
I've worked quite a lot with the DevExpress VerticalGrid in unbound mode in SingleRecordView. We use it in all of our desktop applications that involve lots of data-entry. All data-entry forms are consistent in look-and-feel and so user training is minimal. I think it is a great control.
However, I don't understand how to use it in unbound mode in MultiRecordView layout. I cannot even figure out how to populate the unbound grid with the data for several records. In SingleRecord layout, I use the RowsIterator to move data from my data object in memory into the corresponding row/cell in the VerticalGrid's single record.
But in MultiRecordView layout, I can't figure out how to add the second record and the third record, etc etc, and position the current record pointer so that the RowsIterator is working with the rows of the correct record.
A small code snippet, showing how to move the current record pointer when adding the second and subsequent records in MultiRecordView, would be very helpful.
I've tried AddNewRecord() and setting the FocusedRecord but without success:
for (int i = 0; i < MyTable.Rows.Count; i++)
{
vGridControl1.AddNewRecord();
vGridControl1.FocusedRecord = i;
vGridControl1.RowsIterator.DoOperation(new DataPuller(MyTable.Rows[i]));
}
and here's a relevant snippet from my DataPuller object:
public override void Execute(DevExpress.XtraVerticalGrid.Rows.BaseRow brow)
{
//<snip>
if (brow is DevExpress.XtraVerticalGrid.Rows.EditorRow)
{
string fieldname = brow.Properties.FieldName;
if (table.Columns.Contains(fieldname))
{
brow.Properties.Value = (table[fieldname] == DBNull.Value) ? null : table[fieldname];
}
}
//<snip>
}
The vertical grid doesn't support unbound mode when in MultiRecordView layout.

using the same function but on different rows

I want to estimate the co(variance) matrix of two assets classes (with different derivatives) of every month.. So let's assume that each month is 25 days. I will get the following code,
covar=cov([elec(1:25,:) ngas(1:25,:)])
However, I have like 5 years of data so rewrite everything seems like a waste of time, and I think there has to be an easier way to fix this problem.
ps. I do think the answer to my question is already answered somewhere, but I do not know the words the search on. Thanks for your reply
Sounds like you just need a for loop?
counter = 0;
cover{floor(size(elec,1)/25)} = []; %//Pre-allocation
for day = 1:25:size(elec,1)
counter = counter + 1;
covar{counter}=cov([elec(day:day+25-1,:) ngas(day:day+25-1,:)])
end

With xlwt, How do I set my page/paper size to be "letter" or 8.5X11 instead of A4?

Title basically explains it, but I can't for the life of me get away from the A4 page size and I am having to resize each file individually. I have a LOT of files. Nearly 2000 now, and its kinda getting old.
Thank you to anyone who helps in advance!
sheet.paper_size_code = 1
is what you want.
example:
book = Workbook()
sheet = book.add_sheet('2013')
sheet.paper_size_code = 1
sales_units(OUTPUT, header_list, DATE, book, sheet)
book.save('Projections.xls')

What will be the size(memory)of NSMutableArray?

I am parsing json data,and i store them into an NSMutableArray.
For each data,parameters are as the following format,
{
"id":"6",
"username":"biju",
"password":"biju123",
"usertype":"2",
"first_name":"biju",
"last_name":null,
"email":"b#b.com",
"blocked":"N",
"created":"2012-11-02 16:03:19",
"image":"http:\/\/192.168.1.254\/eatthos\/assets\/upload\/users\/1351852399_thumb.jpg","thumb_image":"1351852399_thumb.jpg",
"menu_image":"0",
"thumb_menu_image":"0",
"city":"njdfh",
"favorite_food":"kafh",
"favorite_restaurant":"kafdhj",
"phone_number":"0",
"description":"0",
"token":"Dwx0DG",
"fb_unique_id":null,
"account_type":"normal",
"twitter_id":null,
"followers":"5",
"follow":"N"
}
i am parsing about 100K of data,what will be the size(memory) of that array ?
Will it be a memory issue if i use it for an iphone app ?
You can try to find out size of your array with the following piece of code :
size_t total;
id obj;
for (obj in array)
{
total += class_getInstanceSize([obj class]);
}
NSLog(#"Array size : %ld",total); //This will return you size in bytes
you need to do : #import <objc/runtime.h>
The array itself won't take that much space -- it's just a bunch of pointers. An array with tens of thousands of items can still only be a few dozen kilobytes. The space taken by the objects that the array contains is likely to be much more significant. But that is something only you can see -- there is no "size of an object in an array." It's like asking "How big is a ball?" It is possible that your data's space needs are problematic, and it's equally possible that there's no problem at all. As with many programming questions, I think the best answer is to try and see for yourself.
Why can not you download 100 records each time like an apps then are in app store
So, That the app will load quicker that before
If u want to see the flow of the memory you can go through this link http://mobileorchard.com/find-iphone-memory-leaks-a-leaks-tool-tutorial/

OpenXML: Issue adding images to documents

Up until now, this block of code has been using to build documents with text for several months with no snags. I am now trying to dynamically add images. I've spent about two days staring at code and researching and am at an end. I suspect the issue is that relationships are not being created (more details below.) Maybe not?
//set stuff up...
WordprocessingDocument doc = WordprocessingDocument.Open(fsPat, true, new OpenSettings(){
AutoSave = true,
MarkupCompatibilityProcessSettings = new MarkupCompatibilityProcessSettings(MarkupCompatibilityProcessMode.ProcessAllParts,
DocumentFormat.OpenXml.FileFormatVersions.Office2007),
MaxCharactersInPart = long.MaxValue
});
MainDocumentPart mainPart = doc.MainDocumentPart;
.
.Other stuff goes here
.
//now the fun...
Run r2 = new Run();
// Add an ImagePart.
ImagePart ip = mainPart.AddImagePart(ImagePartType.Png);
string imageRelationshipID = mainPart.CreateRelationshipToPart(ip); //
using (Stream imgStream = ip.GetStream())
{
System.Drawing.Bitmap b = new System.Drawing.Bitmap("myfile.png");
b.Save(imgStream, System.Drawing.Imaging.ImageFormat.Png);
}
Drawing drawing = BuildImage(imageRelationshipID, "name"+imageRelationshipID.ToString(), 17, 17);
r2.Append(drawing);
p.Append(r2);
The image part is essentially copied from http://blog.stuartwhiteford.com/?p=33) and is running in a loop presently. I also copied his BuildImage() function and use it as-is.
When I open the resulting docx, I see red Xs where the images are saying "This image cannot currently be displayed."
When I open the zip, the images will appear in root/media, but not root/word/media as I'd expect. I also cannot find the images referenced in any of the relationship files. Ideally they'd be in root/word/_rels/document.xml.rels. You'll notice I changed how imageRelationshipID is set hoping to fix this. It didn't.
Please help. Thank you.
So... It seems like OpenXML just hates me. I copied AddImagePart code from like 3-4 places among trying other things--none of which lasted long--and just could not get relationships to form. The implication I see is that they happen automatically with the AddImagePart function.
I ended up doing a complete workaround where I add all the pictures I might want to put and remove the Drawing nodes' parents of the ones I didn't want (Run nodes, generally.) Since these are very small pictures, it's feasible and in ways more elegant than trying to add them as necessary since I don't have to keep track of where images are stored on disk.