Hi,
I am using ASPOSE.PDF for .NET to modify an existing PDF file.
The original file has some place holders, which I then substitute with more meaningful content.
The issue is, as the text changes, the paragraphs lose their horizontal alignments and even leave some strange blank spaces because of that.
I saw that each page has paragraphs, in the document object, but the collection is always coming up empty.
My idea was to do something like this:
foreach (Page page in pdfCombinedDocument.Pages)
{
foreach (BaseParagraph paragraph in page.Paragraphs)
{
paragraph.HorizontalAlignment = HorizontalAlignment.Justify;
}
}
However, it doesn’t work as no paragraphs are returned.
Is there any other solution to achieve the same result?
Thanks.
Hi there,
Thanks for your inquriy. I am afraid currently we cannot manipulate existing paragraphs in PDF document. In your scenario, you may try to set ReplaceAdjustmentAction as following while searching and replacing text. However if the issue persist then please share your sample code along with input/output documents here, so we will look into it and guide you accordingly.
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(“{SomeWord}”);
textFragmentAbsorber.TextReplaceOptions.ReplaceAdjustmentAction = TextReplaceOptions.ReplaceAdjustment.WholeWordsHyphenation;
We are sorry for the inconvenience caused.
Best Regards,
Thanks.
I did add that, as I saw in the documentation before, and it helped. Didn’t entirely fix the issue though.
We are changing the document to not be justified and rolling that way.
Regards.
Hi there,
Thanks for sharing your feedback and it is good to know that you have resolved the issue up to some extend.
However we will appreciate it if you please share your sample PDF document here, so we will look into it and will provide you information accordingly.
We are sorry for the inconvenience caused.
Best Regards,