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.

Fri Jan 25, 2019 12:35 am

i've notice there are new version on this homepage.
my previous version is 4.8.14, so i've replace bunch of dlls.

The Problem is 'PdfGridCellContent' will cause unidentified problem.(or PdfGridCellContentList)
i don't know exact problem what it is.

but if i try old way(below code) on this version(5.1.16)
there are no problem.

Code: Select all
PdfGrid logogrid = new PdfGrid();
                                                            logogrid.Columns.Add(1);
                                                            PdfGridRow logorow = logogrid.Rows.Add();
                                                            logogrid.Columns[0].Width = tWidth;
                                                            logorow.Height = tHeight;
                                                            logorow.Cells[0].Style.BackgroundImage = logo_img;


i've used 'PdfGridCellContent' like this. there are fine on 4.8.14
Code: Select all
                                                            PdfGridCellContentList lst = new PdfGridCellContentList();
                                                            PdfGridCellContent textAndStyle = new PdfGridCellContent();
                                                            textAndStyle.Image = logo_img;
                                                            textAndStyle.ImageSize = new System.Drawing.SizeF(tWidth, tHeight);
                                                            lst.List.Add(textAndStyle);

                                                            cell.Value = lst;

dahami
 
Posts: 21
Joined: Thu Jun 28, 2018 4:39 am

Fri Jan 25, 2019 6:49 am

Hi dahami,

Thanks for your inquiry.
Kindly note we have changed the class "PdfGridCellTextAndStyleList" and "PdfGridCellTextAndStyle" to "PdfGridCellContentList" and "PdfGridCellContent" from Spire.PDF version 4.5.8. With the latest version Spire.PDF Pack(Hot Fix) Version:5.1.16, I could use the class PdfGridCellContentList or PdfGridCellContent successfully and I didn't encounter any issue with your code. Please make sure you have updated the dlls correctly in your project. If there is still the issue, please provide more information, such as the the detailed error information, full code and the input files.

Sincerely,
Anna
E-iceblue support team
User avatar

Anna.Zhang
 
Posts: 73
Joined: Thu Sep 27, 2018 3:20 am

Mon Jan 28, 2019 5:48 am

using PdfGridCellContent with PdfStringFormat is cause 'NullReferenceException' on Grid.Draw(Page,Location)
previous version is no problem. in my case 4.8.14
this error is hard to find. and i really annoying because it's worked just fine before.
anyway i've to check my entire source code, because this is meaning it possible there are new problem on previous working code.
i'm pretty sure, if you have problem to seeing this error then you better check to dlls copied properly.

FYI
if you using PdfGridCellContent(List.Add(Image)) + PdfStringFormat then Error
PdfGridCellContent(List.Add(Text)/* Not setting Font and Brush */) + PdfStringFormat then Error.(but this case is Reasonable.)


PdfGridCellContent(List.Add(Text) /*setting Font and Brush */)
PdfGridCellContent(List.Add(Image)) + PdfStringFormat then Error. <------------ this is serious problem. i can understand above cases because they had logical problems.
but List.Add(Text with Font,Brush) and List.Add(Image) isn't have any logical problems i guess.

i hope you get point.

dahami
 
Posts: 21
Joined: Thu Jun 28, 2018 4:39 am

Mon Jan 28, 2019 10:23 am

Hi,

Sorry for the inconvenience cuased.
Accroding to your information, I used following code to have a test. Unfortunatly, I still cannot reproduce your issue.
Code: Select all
PdfDocument doc = new PdfDocument();
PdfPageBase page = doc.Pages.Add();

PdfGrid grid = new PdfGrid();
grid.Columns.Add(1);
grid.Rows.Add();
grid.Style.CellPadding = new PdfPaddings(1, 1, 1, 1);
float width = page.Canvas.ClientSize.Width - (grid.Columns.Count + 1);
PdfGridRow row = grid.Rows.Add();
grid.Columns[0].Width = width * 0.25f;

PdfGridCellContentList lst = new PdfGridCellContentList();
PdfGridCellContent textAndStyle = new PdfGridCellContent();
textAndStyle.StringFormat = new PdfStringFormat() { Alignment = PdfTextAlignment.Center };
textAndStyle.Image = PdfImage.FromFile("logo.png");
textAndStyle.ImageSize = new SizeF(50, 50);
lst.List.Add(textAndStyle);
row.Cells[0].Value = lst;

PdfLayoutResult result = grid.Draw(page, new PointF(10, 30));
doc.SaveToFile(@"output.pdf", FileFormat.PDF);

To help us reproduce your issue quickly, please share your full code and the related file(input PDF, image file) if any.



Sincerely,
Anna
E-iceblue support team
User avatar

Anna.Zhang
 
Posts: 73
Joined: Thu Sep 27, 2018 3:20 am

Mon Jan 28, 2019 11:40 pm

your code works well.
i think problem is the way approching to set 'StringFormat'

in my case, i've set StringFormat on Cells generally like below article
https://www.e-iceblue.com/Tutorials/Spire.PDF/Spire.PDF-Program-Guide/Table/How-to-merge-cells-in-grid-via-Spire.PDF.html

dahami
 
Posts: 21
Joined: Thu Jun 28, 2018 4:39 am

Tue Jan 29, 2019 2:30 am

Hi,

Thanks for your feedback.
I have reproduced your issue with the code of this article and posted it to our DEV team for fixing. Once there’s any update, I will let you know. Apologize for the inconvenience caused.

Sincerely,
Anna
E-iceblue support team
User avatar

Anna.Zhang
 
Posts: 73
Joined: Thu Sep 27, 2018 3:20 am

Thu Feb 14, 2019 6:48 am

Hi,

Thanks for waiting.
Glad to inform you that the issue is solved in Spire.PDF Pack(Hot Fix) Version:5.2.3.
Our website: https://www.e-iceblue.com/Download/down ... t-now.html
NuGet: https://www.nuget.org/packages/Spire.PDF/

Sincerely,
Betsy
E-iceblue support team
User avatar

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

Return to Spire.PDF