hi,
Hi Richard,
Document pdfDocument = new Document(fileName);
//create TextAbsorber object to find all instances of the input search phrase TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(@"\x5B[a-zA-Z]*\x5D");
</p><p>TextSearchOptions textSearchOptions = new TextSearchOptions(true);
textFragmentAbsorber.TextSearchOptions = textSearchOptions;
//accept the absorber for all the pages pdfDocument.Pages.Accept(textFragmentAbsorber);
//get the extracted text fragments TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments; //loop through the fragments foreach (TextFragment textFragment in textFragmentCollection)
{
//update text and other properties if (textFragment.Text == "[k_aanhefnaam]") { textFragment.Text = "Dear Joe" + i.ToString(); } else if (textFragment.Text == "[k_straatnr]") { textFragment.Text = "Street 10" + i.ToString(); } else if (textFragment.Text == "[k_pcplaats]") { textFragment.Text = "12345 New york " + i.ToString(); } else if (textFragment.Text == "[k_naam]") { textFragment.Text = "Joe " + i.ToString(); } else if (textFragment.Text == "[b_naam]") { textFragment.Text = "Sunset optician " + i.ToString(); } }
pdfDocument.Save(@"c:\CS\pdfs\output_" + i.ToString() + ".pdf");</p>
Hi Richard,
the sake of correction, I have logged it in our issue tracking system as PDFNEWNET-34711. We
will investigate this issue in details and will keep you updated on the status
of a correction.
apologize for your inconvenience.
Any new about this isseu?
richard
Hi Richard,
other priority issues and I am afraid this above stated problem is not yet
resolved. Nevertheless, as soon as we have some updates regarding its resolution, we would
be more than happy to update you with the status of correction. Please be
patient and spare us little time.
Hi Richard,
Nevertheless, if we see Adobe behavior, it doesn’t even allow you to change the text when MyriadPro font is not installed and is removed from Adobe’s Resources installation folder. So Adobe uses the font because it ships the font during Adobe’s installation. The font it must be installed to allow us to use it and its a requirement to make possible to reuse the font.
2) when I have Tags right side aligned and i replace them, they shift to the right. How can I take care that the alignment is as it is in the source pdf?
The Pdf format doesn’t have any information that the tags are right-aligned. So you must manually perform the fragments alignment changing their coordinates. Please use following code snippet that performs the right alignment and works fine when font is installed on the system (Please take a look over attached 34711-installedFont.pdf file):
[C#]
Document pdfDocument = new Document(“c:/pdftest/Tag+test+PDF+(High+Quality+Print)
(1).pdf”);<o:p></o:p>
//create TextAbsorber object to find all instances of the input search phrase
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(@"\[[a-zA-Z_]*\]");
TextSearchOptions textSearchOptions = new TextSearchOptions(true);
textFragmentAbsorber.TextSearchOptions = textSearchOptions;
//accept the absorber for all the pages
pdfDocument.Pages.Accept(textFragmentAbsorber);
TextFragment fragment1 = null;
TextFragment fragment2 = null;
TextFragment fragment3 = null;
//get the extracted text fragments
TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;
//loop through the fragments
foreach (TextFragment textFragment in textFragmentCollection)
{
//update text and other properties
if (textFragment.Text == "[k_aanhefnaam]")
{
textFragment.Text = "Dear Joe";
fragment1 = textFragment;
}
else if (textFragment.Text == "[k_straatnr]")
{
textFragment.Text = "Street 10";
fragment2 = textFragment;
}
else if (textFragment.Text == "[k_pcplaats]")
{
textFragment.Text = "12345 New york";
fragment3 = textFragment;
}
else if (textFragment.Text == "[k_naam]")
{
textFragment.Text = "Joe";
}
else if (textFragment.Text == "[b_naam]")
{
textFragment.Text = "Sunset optician";
}
}
if (fragment1 != null)
fragment1.Position = new Position(500 - fragment1.Rectangle.Width, fragment1.Position.YIndent);
if (fragment2 != null)
fragment2.Position = new Position(500 - fragment2.Rectangle.Width, fragment2.Position.YIndent);
if (fragment3 != null)
fragment3.Position = new Position(500 - fragment3.Rectangle.Width, fragment3.Position.YIndent);
pdfDocument.Save("c:/pdftest/Tag+test+PDF+(High+Quality+Print) (1)_updated.pdf");
The issues you have found earlier (filed as PDFNEWNET-34711) have been fixed in Aspose.Pdf for .NET 7.7.0.
This message was posted using Notification2Forum from Downloads module by aspose.notifier.