Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Mon Nov 14, 2016 9:42 pm

I am currently using a form template. I am iterating over rows of data and filling the form each rows' data then saving it as a differently named PDF. When I go to save it as it's own PDF file I notice that the file size is increasing steadily after each save. I went to check what was causing it and "Overhead Data" seems to increase after each save and I am saving a couple thousand of these so the file size goes into the MBs. For now I am just reloading the file through each iteration but just a heads up since I do not know if this is a bug or just my incompetence :) .

Here's an example code, based on the tutorial.


//during the foreach loop
//doc is the template PDF file.
PdfFormWidget formWidget = doc.Form as PdfFormWidget;
for (int i = 0; i < formWidget.FieldsWidget.List.Count; i++)
{
PdfField field = formWidget.FieldsWidget.List[i] as PdfField;
if (field is PdfTextBoxFieldWidget)
{
PdfTextBoxFieldWidget textBoxField = field as PdfTextBoxFieldWidget;
switch (textBoxField.Name)
{
//Case statement to insert into field, this is potentially sensitive data so I'm leaving it out.
}

}
}
//page is incremented each step, not important.
doc.SaveToFile(workingDir + page.ToString() + ".pdf"); //Saving increases the file size by 6KB each

IWillScoop
 
Posts: 4
Joined: Thu Oct 06, 2016 3:17 pm

Tue Nov 15, 2016 3:39 am

Dear IWillScoop,

Thanks for your inquiry.
I have tested the scenario, but I didn't notice the issue you mentioned.
Please provide us the sample document and tell us how you iterate over rows of data and fill the form each rows' data. For sensitive data, you can replace it with sample data as long as it can reproduce the issue.

Thanks,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.PDF