Problem With Temporary License File

Hi,

I am using using Regular Expressions to search text from Pdf and I want my search result to be colored/highlighted. But when I go for coloring the textfragment having more than 4 words, it throws the following exception-"At most 4 elements (for any collection) can be viewed in evaluation mode".

Can you please help me to find the fix of this issue?

Here is the details of License file

111228122648
f2244f81-f9c1-45db-aa71-ba81a1329eee

Thanks

Hi Prasanth,

Thanks for using our products.

Kindly share some details regarding sample source code and template documents you are using or create a sample application to show the issue. This will help us to figure out the issue and reply back to you soon.

We apologize for your inconvenience.

Thanks & Regards,

Hi,

Following is the piece of code-:

Document pdfDocument = new Document(“webpdf.pdf”);
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber("\bAddressing\W+(?:\w+\W+){1,60}?Abroad\b");

Aspose.Pdf.Text.TextOptions.TextSearchOptions textsearch = new Aspose.Pdf.Text.TextOptions.TextSearchOptions(true);
textFragmentAbsorber.TextSearchOptions = textsearch;
pdfDocument.Pages.Accept(textFragmentAbsorber);
//get the extracted text fragments
TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;

foreach (TextFragment textFragment in textFragmentCollection)//error coming when control goes into this loop
{
//update text and other properties

textFragment.TextState.Font = FontRepository.FindFont(“Verdana”);

textFragment.TextState.FontSize = 15;
textFragment.TextState.ForegroundColor =System.Drawing.Color.Red;

textFragment.TextState.BackgroundColor = System.Drawing.Color.Azure;

}

pdfDocument.Save(“output.pdf”);

Pdf is also attached for your reference. When I search using above regex, following error came when control goes into foreach loop-:
"At most 4 elements (for any collection) can be viewed in evaluation mode."

Could you please help me to fix this issue?

Thanks
Prasanth


Hi Prasanth,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Well, this issue / error comes if the license is not taking affect. If you are using a temporary license, please make sure that the license has not already expired (as it is only valid for 30 days period). If the license is not expired yet, please share your license with us as well. We will test your issue and get back to you soon.

Following are the documentation links for your reference on how to set the license in your application.

Using File or Stream object

Using as Embedded resource

Also, you can see the following link for details regarding how to send the license file:

http://www.aspose.com/corporate/purchase/faqs/send-license-to-aspose-staff.aspx

Sorry for the inconvenience,

Hi,

Thanks for your help in solving that issue. I was missing license file to add into my code.

I am in process of evaluating Aspos features which we can use into our product.
Right now I have a requirement to read a webpage, convert into PDF and apply regular expressions for some text search and highlight.
I am using some other tool to convert a webpage to pdf and then using Aspos on PDF to search and highlight text. But converting webpage to Pdf by that tool is taking a lot of seconds which is depriving us to make our thing as Realtime.

Does Aspos provide any such feature where I can convert my webpage or html page to PDF and then go for search and highlighting text on that PDF or directly take webpage, search and highlight text and then convert it into PDF?

Thanks and Regards,
Tanvi Agrawal


Hi Tanvi,

Thanks for your interest in our products.

Kindly visit the following documentation links for more details and code snippets as per your requirement

How to convert HTML to PDF using InLineHTML approach

Working with Text

Working with Text (Facades)

Please feel free to contact support in case you need any further assistance.

Thanks & Regards,

Hi,

Thanks for you support.
When I am using Inline Html approach, many of my images and style sheets are missed while conversion which is not fulfilling my requirement.

So now I am using Html Agility to load DOM of webpage and which provides me the text of nodes and its Xpath. I apply regular expression and search some text using HTML agility.

For example on web page I searched a word “FIND” but it appears at two places like “FIND JOBS” and at other place as “FIND Books”. I want only one “FIND” to be highlighted which is with “JOBS” not the other one. How can i do it using Aspos?

With HTML Agility I know the Xpath of both these “FIND”
but Aspos understands the position/occurence of it only.
Can Aspos map it with the Xpath of HTML webpage and search the exact match?



Thanks and Regards,
Tanvi Agrawal







Hi Tanvi,

Thanks for your feedback.

gowthampsrl:

When I am using Inline Html approach, many of my images and style sheets are missed while conversion which is not fulfilling my requirement.

Can you please share the template HTML, CSS and images files you are using. This will help us to identify the issue and reply back to you soon.

gowthampsrl:

With HTML Agility I know the Xpath of both these "FIND"
but Aspos understands the position/occurence of it only.
Can Aspos map it with the Xpath of HTML webpage and search the exact match?

I am very sorry to share with you that currently, there are no direct means available in Aspose.Pdf to find text using its position or XPath. However, I have logged this issue with ID: PDFNEWNET-33480 in our bug tracking system. Our development team will further investigate this issue in detail and will update you via this forum thread on the status of correction.

We apologize for your inconvenience.

Thanks & Regards,

Hi,

Thanks for your cooperation.

Right now we are not using Inline Html approach for converting HTML to PDF but for your reference, I tried with this url-::“http://www.educationdynamics.com” and some others but some Style Sheets and Images were missing.

As per our next requirement, Can we" add a Tool Tip and some popup text over it" in PDF using Aspose at any place of the document or at particular text(that text can be search result of regular expressions applied on PDF using Aspose)?


Thanks and Regards,
Tanvi Agrawal

Hi Tanvi,

Thanks for your feedback.

In order to accomplish your requirement please try using FloatingBox, which can be placed anywhere in the PDF file and can display the text with HTML formatting. For more details and code snippets, please visit: Working with Floating Box

Please feel free to contact support in case you need any further assistance.

Thanks & Regards,

gowthampsrl:

As per our next requirement, Can we" add a Tool Tip and some popup text over it" in PDF using Aspose at any place of the document or at particular text(that text can be search result of regular expressions applied on PDF using Aspose)?
Hi Tanvi,

Adding more to Rashid's comments, you may also add Tool tip text to PDF file using Annotations approach. Please visit the following link for information on Working with Annotations

Hi Tanvi,


Thanks for your patience. In reference to PDFNEWNET-33480, please note Aspose.Pdf provide no direct way to find text basing on position or XPath. However, TextFragments has properties Position and Rectangle that allow to map fragment on the page. Also you may specify Rectangle property of TextSearchOptions of TextFragmentAbsorber to limit zone where text searching (or segments absorbing) will be done.

On request: ‘I want only one “FIND” to be highlighted which is with “JOBS” not the other one.’ Our opinion the simplest way to do this using Aspose.Pdf.:

//open document<o:p></o:p>

Document pdfDocument = new Document(myDir

  • “33480_example.pdf”);<o:p></o:p>

    //create TextAbsorber object to find
    all instances of the input search phrase
    <o:p></o:p>

    TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(“JOBS”);<o:p></o:p>

    //accept the absorber for all the pages<o:p></o:p>

    pdfDocument.Pages.Accept(textFragmentAbsorber);<o:p></o:p>

    //get the extracted text fragments<o:p></o:p>

    TextFragmentCollection JobsFragmentCollection =
    textFragmentAbsorber.TextFragments;<o:p></o:p>

    //recreate TextAbsorber object<o:p></o:p>

    textFragmentAbsorber = new
    TextFragmentAbsorber(“FIND”);<o:p></o:p>

    //accept the absorber for all the pages<o:p></o:p>

    pdfDocument.Pages.Accept(textFragmentAbsorber);<o:p></o:p>

    //get the extracted text fragments<o:p></o:p>

    TextFragmentCollection FindFragmentCollection =
    textFragmentAbsorber.TextFragments;<o:p></o:p>

    foreach (TextFragment
    findFragment in FindFragmentCollection)<o:p></o:p>

    {<o:p></o:p>

    //calculate x-position of ‘FIND’ fragment end<o:p></o:p>

    double findFragmentEnd =
    findFragment.Position.XIndent + findFragment.Rectangle.Width;<o:p></o:p>

    foreach (TextFragment
    jobFragment in JobsFragmentCollection)<o:p></o:p>

    {<o:p></o:p>

    //Highlight ‘FIND’ fragment if its position close to ‘JOBS’
    position
    <o:p></o:p>

    if (Math.Abs(findFragment.Position.YIndent

  • jobFragment.Position.YIndent) < 0.1 &&<o:p></o:p>

    Math.Abs(findFragmentEnd -
    jobFragment.Position.XIndent) < jobFragment.TextState.FontSize)<o:p></o:p>


    findFragment.TextState.BackgroundColor = Aspose.Pdf.Color.LightBlue;<o:p></o:p>

    }<o:p></o:p>

    }<o:p></o:p>

    pdfDocument.Save(myDir + “33480_example_highlighted.pdf”);<o:p></o:p>


Please feel free to contact us for any further assistance.

Best Regards,