Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Thu Sep 09, 2021 2:55 am

Hi Forum,

I would like to ask about how can I warp the text to let the long text auto return to the next line
Code: Select all
section.PageNumber = new PdfPageNumber();
        section.PageNumber.NumberStyle = PdfNumberStyle.LowerRoman;
        section.PageNumber.Prefix = "cover ";
        section.PageSettings.Size = PdfPageSize.A4;
        section.PageSettings.Margins.All = 0;
        PdfPageBase page = section.Pages.Add();
        DrawPageHeaderAndFooter(page, margin, true);

        //Cover content
        PdfBrush brush1 = PdfBrushes.Black;
        PdfTrueTypeFont font1 = new PdfTrueTypeFont(new Font("Arial", 18f, FontStyle.Bold));
        PdfStringFormat format = new PdfStringFormat(PdfTextAlignment.Center);
        format.MeasureTrailingSpaces = true;

        string strOwnerName = model.ownername;
        DateTime dtWillCreated = DateTime.Now;
        String text1 = "THE LAST WILL AND TESTAMENT";
        String text2 = "OF";
        String text3 = strOwnerName.Trim().ToUpper();
        String htmlText = "<b>DATED THIS </b>" + "<b>" + dtWillCreated.ToString("dd") + "</b>" + "<b> DAY OF </b>" + "<b>" + dtWillCreated.ToString("MMMM").ToUpper() + "</b>" + " " + "<b>" + dtWillCreated.ToString("yyyy") + "</b>";
        SizeF size = font1.MeasureString(text1, format);
        float pageWidth = page.Canvas.ClientSize.Width;
        float pageHeight = page.Canvas.ClientSize.Height;
        float x = pageWidth / 2, y = 150;
        y = y + margin.Top;
        page.Canvas.DrawString(text1, font1, brush1, x, y, format);
        y = y + font1.MeasureString(text1, format).Height + 100;
        page.Canvas.DrawString(text2, font1, brush1, x, y, format);
        y = y + font1.MeasureString(text2, format).Height + 100;
        page.Canvas.DrawString(text3, font1, brush1, x, y, format);
        y = y + font1.MeasureString(text3, format).Height + 100;

        PdfHTMLTextElement richTextElement = new PdfHTMLTextElement(htmlText, font1, brush1);
        richTextElement.TextAlign = Spire.Pdf.Graphics.TextAlign.Center;

        //Format Layout
        PdfMetafileLayoutFormat HTMLformat = new PdfMetafileLayoutFormat();
        HTMLformat.Layout = PdfLayoutType.Paginate;
        HTMLformat.Break = PdfLayoutBreakType.FitPage;

        //Draw htmlString
        richTextElement.Draw(page.Canvas, new RectangleF(0, y, pageWidth, pageHeight / 2));
        y = y + font1.MeasureString(htmlText, format).Height + 6;

Image
If the text is long, the text3, how i can i make it auto return like warping the text.

lean5503
 
Posts: 10
Joined: Thu Sep 09, 2021 2:41 am

Thu Sep 09, 2021 12:01 pm

Hello,

Thanks for your inquiry.
Please refer to the following code to meet your needs.
Code: Select all
            //page.Canvas.DrawString(text3, font1, brush1, x, y, format);
            PdfStringLayouter textLayouter = new PdfStringLayouter();
            PdfStringLayoutResult result
                = textLayouter.Layout(text3, font1, format, new SizeF(font1.MeasureString(text3, format).Width, font1.MeasureString(text3, format).Height));
            if (result.ActualSize.Width > pageWidth)
            {
                x = x + result.LineHeight;
                result = textLayouter.Layout(text3, font1, format, new SizeF(pageWidth, pageHeight));
            }

            foreach (LineInfo line in result.Lines)
            {
                page.Canvas.DrawString(line.Text, font1, brush1, x, y, format);
                y = y + result.LineHeight;
            }

If this cannot meet your needs, please provide your desired output. You can send it to us ([email protected]) via email. Thanks in advance.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Fri Sep 10, 2021 7:17 am

Brian.Li wrote:Hello,

Thanks for your inquiry.
Please refer to the following code to meet your needs.
Code: Select all
            //page.Canvas.DrawString(text3, font1, brush1, x, y, format);
            PdfStringLayouter textLayouter = new PdfStringLayouter();
            PdfStringLayoutResult result
                = textLayouter.Layout(text3, font1, format, new SizeF(font1.MeasureString(text3, format).Width, font1.MeasureString(text3, format).Height));
            if (result.ActualSize.Width > pageWidth)
            {
                x = x + result.LineHeight;
                result = textLayouter.Layout(text3, font1, format, new SizeF(pageWidth, pageHeight));
            }

            foreach (LineInfo line in result.Lines)
            {
                page.Canvas.DrawString(line.Text, font1, brush1, x, y, format);
                y = y + result.LineHeight;
            }

If this cannot meet your needs, please provide your desired output. You can send it to us ([email protected]) via email. Thanks in advance.

Sincerely,
Brian
E-iceblue support team


Hi Brian,

Thank you so much for helping me, the code wasn't created by me so I'm not familiar with them. The code you provided works fine thank you so much, but it seems like it slightly margin left. Can you help me with it? It would help me a lot.
Image

Also, can you help me with this also?
Code: Select all
//Write Ending START
        text1 = "Signed by";
        rect = new RectangleF(xTab1, y, pageWidth, rect.Height); //set the left alignment start at position 0
        rect = InsertFlexiSignContent(page, rect, text1, false);

        //Check whether require to continue next page START
        if (rect.Location.Y > (page.Canvas.ClientSize.Height - margin.Bottom))
        {
            page = section.Pages.Add();
            DrawPageHeaderAndFooter(page, margin, true);
            y = margin.Top;
            rect = new RectangleF(rect.Location.X, y, rect.Width, rect.Height);
        }
        //Check whether require to continue next page START END
        //Write Ending END

        //Write Ending START
        text1 = "<b>" + owner + "</b>";
        rect = new RectangleF(xTab1, rect.Location.Y, pageWidth, rect.Height); //set the left alignment start at position 0
        rect = InsertFlexiSignContent(page, rect, text1, false);

        //Check whether require to continue next page START
        if (rect.Location.Y > (page.Canvas.ClientSize.Height - margin.Bottom))
        {
            page = section.Pages.Add();
            DrawPageHeaderAndFooter(page, margin, true);
            y = margin.Top;
            rect = new RectangleF(rect.Location.X, y, rect.Width, rect.Height);
        }
        //Check whether require to continue next page START END
        //Write Ending END

        //Write Ending START
        if (model.owneridtype == "NRIC")
        {
            if (r.IsMatch(model.owneridno))
            {
                newText = "(" + model.owneridtype + " No. " + model.owneridno + ")";
            }
            else { newText = "(" + model.owneridtype + " No. " + model.owneridno.Replace(model.owneridno, "") + ")"; }
        }
        else
        {
            if (model.owneridno.Length > 15)
            {
                newText = "(" + model.owneridtype + " " + char.ToUpper(model.owneridno[0]) + model.owneridno.Substring(1, 15) + ")";
            }
            else { newText = "(" + model.owneridtype + " " + char.ToUpper(model.owneridno[0]) + model.owneridno.Substring(1) + ")"; }
        }
        text1 = newText;
        rect = new RectangleF(xTab1, rect.Location.Y, pageWidth, rect.Height); //set the left alignment start at position 0
        rect = InsertFlexiSignContent(page, rect, text1, false);

        //Check whether require to continue next page START
        if (rect.Location.Y > (page.Canvas.ClientSize.Height - margin.Bottom))
        {
            page = section.Pages.Add();
            DrawPageHeaderAndFooter(page, margin, true);
            y = margin.Top;
            rect = new RectangleF(rect.Location.X, y, rect.Width, rect.Height);
        }
        //Check whether require to continue next page START END
        //Write Ending END

        //Write Ending START
        text1 = "as " + gender + " last Will and testament in the";
        rect = new RectangleF(xTab1, rect.Location.Y, pageWidth, rect.Height); //set the left alignment start at position 0       
        InsertFlexiSignContent(page, rect, text1, false);
        text1 = ")";
        rect = new RectangleF(xCenter, rect.Location.Y, pageWidth, rect.Height);
        rect = InsertFlexiSignContent(page, rect, text1, false);

        //Check whether require to continue next page START
        if (rect.Location.Y > (page.Canvas.ClientSize.Height - margin.Bottom))
        {
            page = section.Pages.Add();
            DrawPageHeaderAndFooter(page, margin, true);
            y = margin.Top;
            rect = new RectangleF(rect.Location.X, y, rect.Width, rect.Height);
        }
        //Check whether require to continue next page START END
        //Write Ending END

        //Write Ending START
        text1 = "presence of us both, present at the";
        rect = new RectangleF(xTab1, rect.Location.Y, pageWidth, rect.Height); //set the left alignment start at position 0
        InsertFlexiSignContent(page, rect, text1, false);
        text1 = ")";
        rect = new RectangleF(xCenter, rect.Location.Y, pageWidth, rect.Height);
        rect = InsertFlexiSignContent(page, rect, text1, false);

        //Check whether require to continue next page START
        if (rect.Location.Y > (page.Canvas.ClientSize.Height - margin.Bottom))
        {
            page = section.Pages.Add();
            DrawPageHeaderAndFooter(page, margin, true);
            y = margin.Top;
            rect = new RectangleF(rect.Location.X, y, rect.Width, rect.Height);
        }
        //Check whether require to continue next page START END
        //Write Ending END

        //Write Ending START
        text1 = "same time who at " + gender + " request in";
        rect = new RectangleF(xTab1, rect.Location.Y, pageWidth, rect.Height); //set the left alignment start at position 0
        InsertFlexiSignContent(page, rect, text1, false);
        text1 = ")";
        rect = new RectangleF(xCenter, rect.Location.Y, pageWidth, rect.Height);
        rect = InsertFlexiSignContent(page, rect, text1, false);

        //Check whether require to continue next page START
        if (rect.Location.Y > (page.Canvas.ClientSize.Height - margin.Bottom))
        {
            page = section.Pages.Add();
            DrawPageHeaderAndFooter(page, margin, true);
            y = margin.Top;
            rect = new RectangleF(rect.Location.X, y, rect.Width, rect.Height);
        }
        //Check whether require to continue next page START END
        //Write Ending END

        //Write Ending START
        text1 = "the presence of each other have";
        rect = new RectangleF(xTab1, rect.Location.Y, pageWidth, rect.Height); //set the left alignment start at position 0
        InsertFlexiSignContent(page, rect, text1, false);
        text1 = ")";
        rect = new RectangleF(xCenter, rect.Location.Y, pageWidth, rect.Height);
        rect = InsertFlexiSignContent(page, rect, text1, false);

        //Check whether require to continue next page START
        if (rect.Location.Y > (page.Canvas.ClientSize.Height - margin.Bottom))
        {
            page = section.Pages.Add();
            DrawPageHeaderAndFooter(page, margin, true);
            y = margin.Top;
            rect = new RectangleF(rect.Location.X, y, rect.Width, rect.Height);
        }
        //Check whether require to continue next page START END
        //Write Ending END

        //Write Ending START
        text1 = "hereunto subscribed our names as";
        rect = new RectangleF(xTab1, rect.Location.Y, pageWidth, rect.Height); //set the left alignment start at position 0
        InsertFlexiSignContent(page, rect, text1, false);
        text1 = ")";
        rect = new RectangleF(xCenter, rect.Location.Y, pageWidth, rect.Height);
        rect = InsertFlexiSignContent(page, rect, text1, false);

        //Check whether require to continue next page START
        if (rect.Location.Y > (page.Canvas.ClientSize.Height - margin.Bottom))
        {
            page = section.Pages.Add();
            DrawPageHeaderAndFooter(page, margin, true);
            y = margin.Top;
            rect = new RectangleF(rect.Location.X, y, rect.Width, rect.Height);
        }
        //Check whether require to continue next page START END
        //Write Ending END

        //Write Ending START
        text1 = "witnesses";
        rect = new RectangleF(xTab1, rect.Location.Y, pageWidth, rect.Height); //set the left alignment start at position 0
        InsertFlexiSignContent(page, rect, text1, false);
        text1 = ")";
        rect = new RectangleF(xCenter, rect.Location.Y, pageWidth, rect.Height);
        rect = InsertFlexiSignContent(page, rect, text1, true);

        //Check whether require to continue next page START
        if (rect.Location.Y > (page.Canvas.ClientSize.Height - margin.Bottom))
        {
            page = section.Pages.Add();
            DrawPageHeaderAndFooter(page, margin, true);
            y = margin.Top;
            rect = new RectangleF(rect.Location.X, y, rect.Width, rect.Height);
        }
        //Check whether require to continue next page START END
        //Write Ending END

        y = rect.Location.Y + (font3.MeasureString(text1, alignJustify).Height * 2) + 5; //Add 2 new lines and move down 10 ,initially +10

        //Write Ending Sign START
        text1 = ".......................................";
        rect = new RectangleF(xTab1, y, pageWidth, rect.Height); //set the left alignment start at position 0
        InsertFlexiSignContent(page, rect, text1, false);
        rect = new RectangleF(xSign, rect.Location.Y, pageWidth, rect.Height);
        rect = InsertFlexiSignContent(page, rect, text1, false);

        //Check whether require to continue next page START
        if (rect.Location.Y > (page.Canvas.ClientSize.Height - margin.Bottom))
        {
            page = section.Pages.Add();
            DrawPageHeaderAndFooter(page, margin, true);
            y = margin.Top;
            rect = new RectangleF(rect.Location.X, y, rect.Width, rect.Height);
        }
        //Check whether require to continue next page START END
        //Write Ending Sign END

        //Write Ending Sign START
        text1 = "Witness:";
        rect = new RectangleF(xTab1, rect.Location.Y, pageWidth, rect.Height); //set the left alignment start at position 0
        InsertFlexiSignContent(page, rect, text1, false);
        rect = new RectangleF(xSign, rect.Location.Y, pageWidth, rect.Height);
        rect = InsertFlexiSignContent(page, rect, text1, false);

        //Check whether require to continue next page START
        if (rect.Location.Y > (page.Canvas.ClientSize.Height - margin.Bottom))
        {
            page = section.Pages.Add();
            DrawPageHeaderAndFooter(page, margin, true);
            y = margin.Top;
            rect = new RectangleF(rect.Location.X, y, rect.Width, rect.Height);
        }
        //Check whether require to continue next page START END
        //Write Ending Sign END

        //Write Ending Sign START
        text1 = "Name:";
        rect = new RectangleF(xTab1, rect.Location.Y, pageWidth, rect.Height); //set the left alignment start at position 0
        InsertFlexiSignContent(page, rect, text1, false);
        rect = new RectangleF(xSign, rect.Location.Y, pageWidth, rect.Height);
        rect = InsertFlexiSignContent(page, rect, text1, false);

        //Check whether require to continue next page START
        if (rect.Location.Y > (page.Canvas.ClientSize.Height - margin.Bottom))
        {
            page = section.Pages.Add();
            DrawPageHeaderAndFooter(page, margin, true);
            y = margin.Top;
            rect = new RectangleF(rect.Location.X, y, rect.Width, rect.Height);
        }
        //Check whether require to continue next page START END
        //Write Ending Sign END

        //Write Ending Sign START     
        text1 = "NRIC No.:";
        rect = new RectangleF(xTab1, rect.Location.Y, pageWidth, rect.Height); //set the left alignment start at position 0
        InsertFlexiSignContent(page, rect, text1, false);
        rect = new RectangleF(xSign, rect.Location.Y, pageWidth, rect.Height);
        rect = InsertFlexiSignContent(page, rect, text1, false);

        //Check whether require to continue next page START


Image

The text is slightly been blocked, thank you so much if these can be solved.

lean5503
 
Posts: 10
Joined: Thu Sep 09, 2021 2:41 am

Fri Sep 10, 2021 9:32 am

Hello,

Thanks for your feedback.
Please refer to the following modified code.
Code: Select all
            //page.Canvas.DrawString(text3, font1, brush1, x, y, format);
            PdfStringLayouter textLayouter = new PdfStringLayouter();
            PdfStringLayoutResult result
                = textLayouter.Layout(text3, font1, format, new SizeF(font1.MeasureString(text3, format).Width, font1.MeasureString(text3, format).Height));
            if (result.ActualSize.Width > pageWidth- pdf.PageSettings.Margins.Left - pdf.PageSettings.Margins.Right)
            {
                result = textLayouter.Layout(text3, font1, format, new SizeF(pageWidth- pdf.PageSettings.Margins.Left - pdf.PageSettings.Margins.Right, pageHeight));
            }

            foreach (LineInfo line in result.Lines)
            {
                page.Canvas.DrawString(line.Text, font1, brush1, x, y, format);
                y = y + result.LineHeight;
            }

If there is any question, just feel free to contact us.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Mon Sep 13, 2021 1:28 am

HI Brian,

How bout this,
Code: Select all
        text1 = "<b>" + owner + "</b>";
        rect = new RectangleF(xTab1, rect.Location.Y, pageWidth, rect.Height); //set the left alignment start at position 0
        rect = InsertFlexiSignContent(page, rect, text1, false);

        //Check whether require to continue next page START
        if (rect.Location.Y > (page.Canvas.ClientSize.Height - margin.Bottom))
        {
            page = section.Pages.Add();
            DrawPageHeaderAndFooter(page, margin, true);
            y = margin.Top;
            rect = new RectangleF(rect.Location.X, y, rect.Width, rect.Height);
        }


Image

lean5503
 
Posts: 10
Joined: Thu Sep 09, 2021 2:41 am

Mon Sep 13, 2021 9:20 am

Hello,

Thanks for your inquiry.
I simulated the complete code based on the code snippet you provided for testing, but I did not reproduce your issue. Please provide your desired output and your complete code (or a runnable project) to help us investigate further. You can send them to us ([email protected]) via email. Thanks in advance.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Mon Sep 13, 2021 10:29 am

Hi Brian,

Thank you so much for your help, i do upload in google drive, maybe this can help? The code where the name will input is line 900

https://drive.google.com/file/d/1nBG0pAL2wg35BEDMRIw3J6XxoA08pOAZ/view?usp=sharing

Image

lean5503
 
Posts: 10
Joined: Thu Sep 09, 2021 2:41 am

Tue Sep 14, 2021 8:01 am

Hello,

Thanks for your sharing.
According to your code, the problem should be your custom method "InsertFlexiSignContent()" or "DrawPageHeaderAndFooter()", but your code does not contain the definition of these two methods. I suggest you refer to the code I provided earlier and use the "textLayouter.Layout()" method to set the layout of the text drawn into the PDF file. If it still doesn't work, please provide the detailed code of your custom method "InsertFlexiSignContent()" or "DrawPageHeaderAndFooter()".

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Tue Sep 14, 2021 8:46 am

Brian.Li wrote:Hello,

Thanks for your sharing.
According to your code, the problem should be your custom method "InsertFlexiSignContent()" or "DrawPageHeaderAndFooter()", but your code does not contain the definition of these two methods. I suggest you refer to the code I provided earlier and use the "textLayouter.Layout()" method to set the layout of the text drawn into the PDF file. If it still doesn't work, please provide the detailed code of your custom method "InsertFlexiSignContent()" or "DrawPageHeaderAndFooter()".

Sincerely,
Brian
E-iceblue support team


Hi Brian,

Thank you for helping! I have done fixed it.
Image
Code: Select all
        //Write Ending START
        text1 = "<b>" + owner + "</b>";
        rect = new RectangleF(xTab1, rect.Location.Y, pageTab1Width, rect.Height); //set the left alignment start at position 0
        rect = InsertFlexiSignContent(page, rect, text1, false);

i modified the pageTab1Width from pageWidth. Which is
Code: Select all
 
float pageWidth = page.Canvas.ClientSize.Width;
float pageTab1Width = page.Canvas.ClientSize.Width - xTab1;


The xTab1 is = 20
Code: Select all
float xTab1 = 20;


But then i found another issue again, there is percentage number beside the name as the right of the name, i provided the whole page of c# code then, the code is start from line 1163.

https://drive.google.com/file/d/15N0L3_ibeZP5BL7wrYnlQV1dvC0j3XtY/view?usp=sharing

Image

Thank you so much for your help!

lean5503
 
Posts: 10
Joined: Thu Sep 09, 2021 2:41 am

Tue Sep 14, 2021 11:02 am

Hello,

Thanks for your feedback
Unfortunately your code still contains some methods and I'm not able run it directly. But based on the screenshot you provided, I suspect the issue is related to line 1178/1202 in your code (benefiDetails.Add(_otherBeneficiary[i].shareallocation + "%");). I suggest that you try commenting out this line.
If there are still any problems, to help us reproduce your issue and help you solve it, please provide the complete executable code. Thanks in advance.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Tue Sep 14, 2021 5:11 pm

Brian.Li wrote:Hello,

Thanks for your feedback
Unfortunately your code still contains some methods and I'm not able run it directly. But based on the screenshot you provided, I suspect the issue is related to line 1178/1202 in your code (benefiDetails.Add(_otherBeneficiary[i].shareallocation + "%");). I suggest that you try commenting out this line.
If there are still any problems, to help us reproduce your issue and help you solve it, please provide the complete executable code. Thanks in advance.

Sincerely,
Brian
E-iceblue support team


Sorry that, i may unable to provide whole workable code, cause its company's property.
The percentage number is needed, I like to make it like make the long string return to the next line when reach the percentage there, so that the percentage number wont overlay by the long string. This is screenshot bellow.. But if the text is too long when it reach the percentage there, i would like it to return to the next line.
Maybe do you have any example for this ?
Image
Image

lean5503
 
Posts: 10
Joined: Thu Sep 09, 2021 2:41 am

Wed Sep 15, 2021 7:23 am

Hello,

Thanks for your response.
We recommend that you refer to the following code.
Code: Select all
            format = new PdfStringFormat(PdfTextAlignment.Left);
            string percentage = "60%";
            float percentageWidth = font1.MeasureString(percentage, format).Width;
            page.Canvas.DrawString(percentage, font1, brush1, pageWidth - percentageWidth, y, format);


            PdfStringLayouter textLayouter = new PdfStringLayouter();
            PdfStringLayoutResult result
                = textLayouter.Layout(text3, font1, format, new SizeF(font1.MeasureString(text3, format).Width, font1.MeasureString(text3, format).Height));
            if (result.ActualSize.Width > pageWidth - percentageWidth)
            {
                result = textLayouter.Layout(text3, font1, format, new SizeF(pageWidth - percentageWidth-50, font1.MeasureString(text3, format).Height));
            }

            foreach (LineInfo line in result.Lines)
            {
                page.Canvas.DrawString(line.Text, font1, brush1, 0, y, format);
                y = y + result.LineHeight;
            }


            PdfTextWidget textWidget = new PdfTextWidget(result.Remainder, font1, brush1);
            PdfTextLayout textLayout = new PdfTextLayout();
            textLayout.Break = PdfLayoutBreakType.FitPage;
            textLayout.Layout = PdfLayoutType.Paginate;
            RectangleF bounds = new RectangleF(new PointF(0, y), page.Canvas.ClientSize);
            textWidget.StringFormat = format;
            textWidget.Draw(page, bounds, textLayout);


Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Fri Sep 17, 2021 6:21 am

Brian.Li wrote:Hello,

Thanks for your response.
We recommend that you refer to the following code.
Code: Select all
            format = new PdfStringFormat(PdfTextAlignment.Left);
            string percentage = "60%";
            float percentageWidth = font1.MeasureString(percentage, format).Width;
            page.Canvas.DrawString(percentage, font1, brush1, pageWidth - percentageWidth, y, format);


            PdfStringLayouter textLayouter = new PdfStringLayouter();
            PdfStringLayoutResult result
                = textLayouter.Layout(text3, font1, format, new SizeF(font1.MeasureString(text3, format).Width, font1.MeasureString(text3, format).Height));
            if (result.ActualSize.Width > pageWidth - percentageWidth)
            {
                result = textLayouter.Layout(text3, font1, format, new SizeF(pageWidth - percentageWidth-50, font1.MeasureString(text3, format).Height));
            }

            foreach (LineInfo line in result.Lines)
            {
                page.Canvas.DrawString(line.Text, font1, brush1, 0, y, format);
                y = y + result.LineHeight;
            }


            PdfTextWidget textWidget = new PdfTextWidget(result.Remainder, font1, brush1);
            PdfTextLayout textLayout = new PdfTextLayout();
            textLayout.Break = PdfLayoutBreakType.FitPage;
            textLayout.Layout = PdfLayoutType.Paginate;
            RectangleF bounds = new RectangleF(new PointF(0, y), page.Canvas.ClientSize);
            textWidget.StringFormat = format;
            textWidget.Draw(page, bounds, textLayout);


Sincerely,
Brian
E-iceblue support team



I still have no idea...
Code: Select all
                            alphacounter = 'a';
                            strContent = "I give my undivided share in the property known as " + _otherBeneficiary[i].giftDes +
                                " to the following beneficiaries in accordance with the entitlement set out below:";
                            intSeqNo++;
                            DrawNumContent(ref rect, section, ref page, margin, x, ref y, intSeqNo, strContent);
                            List<String> benefiDetails = new List<string>();
                            benefiDetails.Add("(" + alphacounter.ToString() + ")      ");

                            benefiDetails.Add(q2bene);
                            if (_otherBeneficiary[i].idType == "NRIC")
                            {
                                benefiDetails.Add(" (" + _otherBeneficiary[i].idType + " No. " + _otherBeneficiary[i].idNo + ") ");
                            }
                            else
                            {
                                benefiDetails.Add(" (" + _otherBeneficiary[i].idType + " " + char.ToUpper(_otherBeneficiary[i].idNo[0]) + _otherBeneficiary[i].idNo.Substring(1) + ") ");
                            }
                           
                            benefiDetails.Add(_otherBeneficiary[i].shareallocation + " %");

                            DrawBeneficiary(ref rect, section, ref page, margin, x, ref y, benefiDetails);



                            alphacounter++;


maybe can you help me from this codes how to fix. i have no idea how that percentage number can margin right without any method

lean5503
 
Posts: 10
Joined: Thu Sep 09, 2021 2:41 am

Fri Sep 17, 2021 10:11 am

Hello,

Thanks for your feedback.
Because your code contains some custom methods and parameters, I cannot run it directly on my side. I tried to modify your code for testing, but unfortunately did not reproduce your problem. Based on the current information, we are not able to locate the cause and provide you with a solution.
To help us further look into your issue, could you please simplify the key code in your project and provide us with a simple runnable project that can reproduce your issue? You could share the project with us ([email protected]) via email. Thanks in advance for your assistance and understanding.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Mon Sep 20, 2021 5:27 am

Brian.Li wrote:Hello,

Thanks for your feedback.
Because your code contains some custom methods and parameters, I cannot run it directly on my side. I tried to modify your code for testing, but unfortunately did not reproduce your problem. Based on the current information, we are not able to locate the cause and provide you with a solution.
To help us further look into your issue, could you please simplify the key code in your project and provided us with a simple runnable project that can reproduce your issue? You could share the project with us ([email protected]) via email. Thanks in advance for your assistance and understanding.

Sincerely,
Brian
E-iceblue support team


Hi Brain
Code: Select all
        //Draw ShareAlc align right
        text1 = sharealc;
        //Render HTML text
        PdfBrush brush = PdfBrushes.Black;
        PdfHTMLTextElement richTextElement = new PdfHTMLTextElement(text1, font3, brush);


Can I make the text margin left like only a bit

lean5503
 
Posts: 10
Joined: Thu Sep 09, 2021 2:41 am

Return to Spire.PDF