Hi All!
I'm trying to implement Layout on a text added to an existing PDF since the text overflows the current margins of the paper.
The problem remains on the fact that the loaded PDF is being signed, and all operations are conducted on PDFLoadedPage, when I get an error &80004002 ("cannot convert Syncfusion.Pdf.Pdfloadedpage to type Syncfusion.PDF.PDFPage").
Basically the code is:
Dim page As PdfPageBase =
loadedDocument.Pages(loadedDocument.Pages.Count - 1)
Dim Line as Single = 10
Dim W as Single = 500
Dim H as Single = 800
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 8)
Dim textElement As PdfTextElement = New PdfTextElement("This is a sample of text that cannot be correctly set into two lines of the page", font)
Dim layoutResult As PdfLayoutResult = textElement.Draw(page, New RectangleF(10, Line, W, H))
So, how to perform an advanced text layout during the digital-signing of a PDF to fix big text in many lines?
Thanks in advance.
Hi DavidBS,
We don't have support to draw TextElement with layout text
by using PdfLoadedPage instance .Instead, we can able to achieve your
requirement of drawing text with layout preserved using DrawString Method of PdfGraphics class.we have attached a sample to draw a text using DrawString
Method with the output document for your reference. Please try this in your end
and let us know if it satisfies your requirement.
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/ConsoleSample819857021
Document: https://www.syncfusion.com/downloads/support/directtrac/general/pd/Output-941219662
Please refer to the following link for more information,
https://help.syncfusion.com/file-formats/pdf/working-with-text
Please let us know if you need any further assistance in this.
Regards,
Irfana J.
Hi Irfana!
Hmmm... I guess I was not clear enough.
My problem is not to set the text in different lines but how to correctly set a big paragraph text into a page without the need to create it in DOC mode and has to convert it after.
Anyway, my point is: why PDFTEXTELEMENT (that makes it!) cannot be utilized with PDfLoadedPage, which is required to sign a document digitally? We cannot add a page with free text and METADATA and sign the paper in a single step.
And, if possible, which will be a way to bypass this limitation?
Regards,
David
Hi DavidBS,
As we have already said we provide support to draw large text with PdfTextElement but only with PdfPage Instance. For an existing document we should use DrawString Method from page graphics to draw the text with different PdfStringformat constraints. We have attached the code snippet to draw the text element in an existing document. Please try this in your end and let us know if it satisfies your requirement.
PdfGraphics graphics = page.Graphics; PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 8); //Create a new PDF string format instance. graphics.DrawString(text, font, PdfBrushes.Black, new PointF(0, 0),format); document.Save("../../../Output.pdf"); |
Please follow the below links for more information:
https://help.syncfusion.com/cr/file-formats/Syncfusion.Pdf.Graphics.PdfGraphicsElement.html
Please let us know if you need any further assistance in this.
Regards,
Irfana J.