We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Carriage Return OR Paragraph Break For Text Fragments Problem (Square Char Problem)

Hi I'm trying to replace a text fragment with a set of paragraphs.
I load a template PDF file in, and find a placeholder in my template using the TextFragmentAbsorber to search each page.
I want to replace the text of the placeholder with some text, implementing paragraphs where the replacement text has a separator of ':p:'.
However when I do this the PDF renders a square character.
Any ideas?
I'm using v6.9 and v7.0, both have the problem

Please note both \r\n and \v don't work, both render the square character...
Is this a known bug, is their an alternative?

p.s. SplitOnString() is a custom extension method.

CODE:
string textToFind = "##NAMES_PLACEHOLDER##";
string replacementString = "Hello how are you:p:I hope well:p:See you soon";

try
{
//open document
Document pdfDocument = new Document(Server.MapPath("~/template/") + "TemplateReport.pdf");
string[] substrings = replacementString.SplitOnString(":p:");

if (substrings.Length > 1)
{
//create TextAbsorber object to find all instances of the input search phrase
TextFragmentAbsorber txtMultipleAbsorber = new TextFragmentAbsorber(textToFind);

//accept the absorber for all the pages
pdfDocument.Pages.Accept(txtMultipleAbsorber);


//get the extracted text fragments
TextFragmentCollection textFragmentMultiCollection = txtMultipleAbsorber.TextFragments;

// look though all the text fragments that mee the absorber criteria
foreach (TextFragment textFragment in textFragmentMultiCollection)
{
textFragment.Text = string.Empty;

for (int idx = 0; idx < substrings.Length; idx++)
{
if (textFragment.Text == string.Empty)
textFragment.Text = substrings[idx];
else
textFragment.Text += "\v" + substrings[idx];
}
}
}
else
{
//create TextAbsorber object to find all instances of the input search phrase
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(textToFind);

//accept the absorber for all the pages
pdfDocument.Pages.Accept(textFragmentAbsorber);

//get the extracted text fragments
TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;

foreach (TextFragment textFragment in textFragmentCollection)
{
textFragment.Text = replacementString;
}
}

I’ve had the same problem this week - the character in question was the LF char (chr(10)).
All I could do was to try to ensure CRLFs (chr(13) & chr(10)) were just using CRs (chr(13)).

This only happened on certain PCs too - mine was fine but my workmate’s wasn’t and I couldn’t find the missing link.

Also, this didn’t seem to be just an aspose problem, as the same happened when saving as PDF in MSWord on the offending PC.

Hi,


Sorry for the delayed response.

We are working over this query and will get back to you soon. Sorry for the delay and inconvenience.

Hi Code warrior,

Thanks for your reply. I work with the original poster and it’s great you’re looking into our issue. Unfortunately we’ve encountered this issue at a key point of our project and really need to get an idea of how quickly we might be able to get to a resolution. It would be great to know if you think this might be a bug in aspose, something to do with our implementation or if you have any suggestions for other methods we might use to replace multiple paragraphs within a PDF.

Thanks

Tim

Hi,


Thanks for your patience and sorry for the delayed response.

I have gone through the problem description and I am afraid I am unable to replicate this scenario in my environment. Can you please share the sample project along with the source PDF document that you are using so that we can test the scenario at our end. We are sorry for your inconvenience.

Hi,

Can you let us know how we can share this code/template with you?

Thanks

Hi,


In order to share the project/file, you can Archive the project/resource files and attach them with in this forum thread. Please notice the File Attachment button at the bottom of Text Area when creating a post. If you encounter any issue, you may consider uploading the file over some FTP share the link with us. We are sorry for your inconvenience.

Hi,

I am experiencing the same issue. Was this ever resolved?

Hi Salomon,


Thanks for your inquiry. I’m afraid, we are unable to replicate the issue. Could you please share your sample code along with source Pdf document here? So we will look into it and provide you more information accordingly.

Sorry for the inconvenience faced.

Best Regards,

Hi,

Attached is a small sample project illustrating the issue. See notes on line 34.

I look forward to hearing back from you regarding your findings.

SG

Hi Salomon,

Sorry for the inconvenience faced. I have managed to observed the reported issue on my side and logged it in our bug tracking system as PDFNEWNET-35114 for further investigation and resolution. I've also linked your request to this issue and you will be notified as soon as it is resolved via this thread.


Please feel free to contact us for any further assistance.


Best Regards,

The issues you have found earlier (filed as PDFNEWNET-35114) have been fixed in Aspose.Pdf for .NET 9.8.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.