Free Support Forum - aspose.com

How can I wrap the text before it goes across a line?

To whom it may concerns,

I’d love to learn how to wrap the text which went beyond the line and even the boundary on the right side of output PDF file below.

Input with shorter texts 2017112144212.pdf (105.0 KB)
Output with replaced longer texts and log file 2017112144212_jaen_out2.zip (183.0 KB)

You’ll easily find the target line on the right top; “The Saga labor bureau labor standard part (the director department)” which I prefer to be wrapped inside the box.

I did search this forum and read some 50-ish topics, including this but I’m not quite sure how to do it.

I read this and included the log file in the above zip archive for more information.

I’m using Aspose.Pdf for .NET ver 18.5.0.
Thank you for your team’s support.

  • I corrected the attachment files

@KDSSHO

Thank you for contacting support.

We would like to request you to use below code snippet in your environment and then share your kind feedback with us. It replaces the text without overlapping the boundary of the rectangle.

        Document doc = new Document(dataDir +  "2017112144212.pdf");
        TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(@"佐賀労働局労働基準部(監督課)");
        textFragmentAbsorber.TextReplaceOptions.ReplaceAdjustmentAction =   TextReplaceOptions.ReplaceAdjustment.WholeWordsHyphenation;
        doc.Pages.Accept(textFragmentAbsorber);
        TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;
        foreach (TextFragment textFragment in textFragmentCollection)
        {
            textFragment.Text = @"The Saga labor bureau labor standard part (the director department)";
        }
        doc.Save(dataDir + "Test_18.5.pdf");

We have attached generated PDF file for your kind reference Test_18.5.pdf. We hope this will be helpful. Please feel free to contact us if you need any further assistance.

Hi Farhan,

Thank you very much for teaching me the option effective to my issue.
However this doesn’t suffice.
I’d like no text in the page to run over on the right side.
Please find the attached file. All the lines are running over to the right.
2017112144212_jaen_out_suggestedOptionSet.pdf (260.4 KB)

I did customize 2 lines in your snippet as follows.


// TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(@"佐賀労働局労働基準部(監督課)");
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(".+");

// textFragment.Text = @"The Saga labor bureau labor standard part (the director department)";
textFragment.Text = textTranslator.doTranslation(textFragment.Text.ToString());

I’d like to “translate” the PDF.
Now I realized I failed to put the important link to my own snippet and my scenario.

I am truly sorry not letting you know what my intention is like.
I understand the option “TextReplaceOptions.ReplaceAdjustment.WholeWordsHyphenation” is effective in some cases.

Would you kindly advise me if there is another tips fully effective for my scenario?
Thanks again.

@KDSSHO

Thank you for elaborating the details.

We have tested the scenario and have been able to notice the problem of text overflow. A ticket with ID PDFNET-44812 has been logged in our issue management system for further investigation and resolution. The ticket ID has been linked with this thread so that you will receive notification as soon as the ticket is resolved.

We are sorry for the inconvenience.

Hi Farhan,

Thank you for your cooperation.
Please keep me posted.

@KDSSHO

We will keep you informed about any available updates regarding this ticket. We appreciate your patience and comprehension in this regard.

Hi Farhan,

Would you kindly suggest me when this is going to be fixed?
As far as I know the below release doesn’t mention this issue.
https://docs.aspose.com/display/pdfnet/Aspose.PDF+for+.NET+18.6+Release+Notes

If I make a ticket on the Paid Support System, is this report going to be prioritized?

@KDSSHO

Thank you for getting back to us.

The logged ticket is pending for investigations owing to previously logged issues in the queue. We have recorded your request for ETA and will update you as soon as some information will be available. Since this ticket is currently logged under free support model, the resolution can take several months. Whereas, tickets logged under Paid Support are resolved earlier because of more priority.

In case you are not already subscribed to Paid Support, you may please consider subscribing for it. For further information, please visit Paid Support FAQs.