Compiling error on Aspose ducument sample code

The following code is copied from Aspose ducument, with

Imports Aspose.Pdf

Imports Aspose.Pdf.Facades

Imports Aspose.Pdf.Color

in .NET 2008 IDE

The Gray colored part says "Type ... is not defined."

'open document

Dim pdfDocument As New Document("input.pdf")

'create TextAbsorber object to find all instances of the input search phrase

Dim textFragmentAbsorber As New TextFragmentAbsorber("\d{4}-\d{4}") 'like 1999-2000

'set text search option to specify regular expression usage

Dim textSearchOptions As New TextSearchOptions(True)

textFragmentAbsorber.TextSearchOptions = textSearchOptions

'accept the absorber for all the pages

pdfDocument.Pages.Accept(textFragmentAbsorber)

'get the extracted text fragments

Dim textFragmentCollection As TextFragmentCollection = textFragmentAbsorber.TextFragments

'loop through the fragments

For Each textFragment As TextFragment In textFragmentCollection

'update text and other properties

textFragment.Text = "New Phrase" 'ERROR: Object reference not set

to an instance of an object.

textFragment.TextState.Font = FontRepository.FindFont("Verdana")

textFragment.TextState.FontSize = 22

textFragment.TextState.ForegroundColor =

System.Drawing.Color.Blue

textFragment.TextState.BackgroundColor =

System.Drawing.Color.Green

Next textFragment

pdfDocument.Save("output.pdf")

sxia

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

Please also include the following namespaces in your code and it will work fine without any compile time error.

Imports Aspose.Pdf.Text

Imports Aspose.Pdf.Text.TextOptions

Please feel free to contact support if you need any further assistance or face any issue.

Thank You & Best Regards,

Compiling error has gone, but the code doesn't work for the attached pdf.

my code

'open document

Dim pdfDocument As New Document(outPutFile)

'create TextAbsorber object to find all instances of the input search phrase

Dim textFragmentAbsorber As New TextFragmentAbsorber("[0-9.]*[A-Z.]*[a-z.]*[ ]*Page [0-9]+ of [0-9]+")

'set text search option to specify regular expression usage

Dim textSearchOptions As New TextSearchOptions(True)

textFragmentAbsorber.TextSearchOptions = textSearchOptions

'accept the absorber for all the pages

pdfDocument.Pages.Accept(textFragmentAbsorber)

'get the extracted text fragments

Dim textFragmentCollection As TextFragmentCollection = textFragmentAbsorber.TextFragments

'loop through the fragments

For Each textFragment As TextFragment In textFragmentCollection

'update text and other properties

textFragment.Text = String.Empty

Next textFragment

pdfDocument.Save("output.pdf")

The regular exp "[0-9.]*[A-Z.]*[a-z.]*[ ]*Page [0-9]+ of [0-9]+" works for

'bind input PDF file
contentEditor.BindPdf(outPutFile)

'make sure the regular expression strategy is being used
contentEditor.ReplaceTextStrategy.IsRegularExpressionUsed = True

'specify that you want to replace all the matching string
'by default only the first string will be replaced
contentEditor.ReplaceTextStrategy.ReplaceScope = Aspose.Pdf.Facades.ReplaceTextStrategy.Scope.REPLACE_ALL

'replace any string like 5467-3986-7 with new string
contentEditor.ReplaceText("[0-9.]*[A-Z.]*[a-z.]*[ ]*Page [0-9]+ of [0-9]+", String.Empty)

'save output PDF file
contentEditor.Save(outPutFile)

The code tries to take off the bottom line (e.g. “2.C. page 1 of 95”) of a page

Hello Samuel,

Thanks for using our products.
<span style=“font-size:10.0pt;font-family:“Arial”,“sans-serif””>

I
have tested the scenario and I am able to reproduce the same problem. For the
sake of correction, I have logged it in our issue tracking system as PDFNEWNET-30674. We will investigate this
issue in details and will keep you updated on the status of a correction.<span style=“font-size:10.0pt;font-family:“Arial”,“sans-serif””><span style=“font-size:10.0pt;
font-family:“Arial”,“sans-serif””>

We apologize for your inconvenience.


The issues you have found earlier (filed as 30674 ) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.