Accessing private members of PdfLoadedDocument

hi

I read the FAQ @ https://www.syncfusion.com/faq/windowsforms?categId=110 and tried accessing the m_pageContentLength field but always get a null. My Watch in Visual Studio shows a value though. Is there something wrong with my reflection code:


                    Type typecontroller = document.Pages[i].GetType();
                    FieldInfo fi = typecontroller.GetField("m_pageContentLength", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetField);
                    long pageContentLength = 0;

                    if (fi != null)
                        pageContentLength = (long)fi.GetValue(document.Pages[i]);

Any help will be much appreciated

Zain

3 Replies

SL Sowmiya Loganathan Syncfusion Team May 18, 2020 12:14 PM UTC

Hi Zain,   
  
Thank you for contacting Syncfusion support.   
  
We have checked the provided code snippet to get the non-public member. Could you please let us know for which purpose you need this “m_pageContentLength" private member, it will helpful for us to provide the precise solution on this.   
  
Regards,  
Sowmiya Loganathan  




ZA Zain May 18, 2020 12:44 PM UTC

Hi Sowmiya Loganathan 

I am trying to determine blank pages in a PDF document but the proposed method of checking for images and text fails for some documents.
                  img = document.Pages[i].ExtractImages();   //img is an array
                  txt = document.Pages[i].ExtractText();
I say fail because the image count = 0 and text is null but when viewing the pdf, it has an image on the page. The PDF is not corrupt.

The only variable that proves that the page is not blank is m_pageContentLength > 0


SL Sowmiya Loganathan Syncfusion Team May 19, 2020 02:06 PM UTC

  
Hi Zain,   
  
Thank you for the update.   
  
Could you please provide us the input PDF document which you have facing the issue. It will be helpful for further analysis and provide the better solution on this.   
  
Regards,  
Sowmiya Loganathan  
 



Loader.
Up arrow icon