- Home
- Forum
- ASP.NET Web Forms (Classic)
- Text not showing on pdf?
Text not showing on pdf?
The problem I have is I am opening an existing pdf document, getting the 1st page, and writing some text on it using page.drawstring. Then I save the document. When I open the document in adobe reader, I don't see any text.
When I pick the "Select Text" tool, and choose "Select All", and then choose copy/paste into notepad, I see all my written text.
The only thing I can guess is that the text is written behind everything, is that possible? And how would I bring the text to the front if that's the case? I've tried using all sorts of coordinates to make sure that the text is written on the page, everything from (1,1) to (1100,1100).
I have done this numerous times in the past with no problems, but using a different pdf document. I am using the same code that I've used for the other 20 documents that I have done this with. Any ideas?
When I pick the "Select Text" tool, and choose "Select All", and then choose copy/paste into notepad, I see all my written text.
The only thing I can guess is that the text is written behind everything, is that possible? And how would I bring the text to the front if that's the case? I've tried using all sorts of coordinates to make sure that the text is written on the page, everything from (1,1) to (1100,1100).
I have done this numerous times in the past with no problems, but using a different pdf document. I am using the same code that I've used for the other 20 documents that I have done this with. Any ideas?
SIGN IN To post a reply.
4 Replies
JS
Jason Smith
September 11, 2009 05:24 PM UTC
How are you drawing the text. This type of code is working for me:
PdfLoadedDocument doc = new PdfLoadedDocument(@"C:\test.pdf");
PdfPageBase page = doc.Pages[0];
PdfGraphics graphics = page.Graphics;
PdfTextElement text = new PdfTextElement();
text.Font = new PdfStandardFont(PdfFontFamily.Helvetica, 16, PdfFontStyle.Bold);
text.Text = "Hello World!";
text.Draw(graphics, 100.0f, 100.0f);
doc.Save(@"C:\testresult.pdf");
PdfLoadedDocument doc = new PdfLoadedDocument(@"C:\test.pdf");
PdfPageBase page = doc.Pages[0];
PdfGraphics graphics = page.Graphics;
PdfTextElement text = new PdfTextElement();
text.Font = new PdfStandardFont(PdfFontFamily.Helvetica, 16, PdfFontStyle.Bold);
text.Text = "Hello World!";
text.Draw(graphics, 100.0f, 100.0f);
doc.Save(@"C:\testresult.pdf");
TE
Thiruvenkadam E
Syncfusion Team
September 15, 2009 11:40 AM UTC
Hi Daniel,
Thank you for your interest in Syncfusion products.
Draw text on exiting pdf document
We can able to draw a text on a existing pdf document by using the "public void DrawString(string s, PdfFont font, PdfBrush brush, RectangleF layoutRectangle, PdfStringFormat format)" method.
Could you please find the sample from the below location and let me know if this helps.
http://files.syncfusion.com/support/Pdf.Windows/F89879/Text.zip
Please have a look at the above sample and if still the issue exists,
Could you please try to reproducing it in the above sample or send us few documents so that we could sort out the cause of the issue and provide you a solution?
Please let us know if you need any further information.
Regards,
Thiru
Thank you for your interest in Syncfusion products.
Draw text on exiting pdf document
We can able to draw a text on a existing pdf document by using the "public void DrawString(string s, PdfFont font, PdfBrush brush, RectangleF layoutRectangle, PdfStringFormat format)" method.
Could you please find the sample from the below location and let me know if this helps.
http://files.syncfusion.com/support/Pdf.Windows/F89879/Text.zip
Please have a look at the above sample and if still the issue exists,
Could you please try to reproducing it in the above sample or send us few documents so that we could sort out the cause of the issue and provide you a solution?
Please let us know if you need any further information.
Regards,
Thiru
JM
Jose Mari
February 28, 2022 01:13 PM UTC
Example cannot be download, is it still avaiable?
GK
Gowthamraj Kumar
Syncfusion Team
March 1, 2022 01:24 PM UTC
Hi Jose,
We have created and attached the sample for drawing a text in existing PDF document. Please find the sample from below link,
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/WebForms_Sample1496671015
Please refer to the below link for more information,
UG: https://help.syncfusion.com/file-formats/pdf/working-with-text#drawing-text-in-an-existing-document
KB: https://www.syncfusion.com/kb/9789/how-to-draw-multiline-text-in-pdf-using-c-and-vb-net
Please let us know if you have any further assistance about this.
Please let us know if you have any further assistance about this.
Regards,
Gowthamraj K
SIGN IN To post a reply.
- 4 Replies
- 5 Participants
-
DC Daniel Carnahan
- Sep 9, 2009 03:06 PM UTC
- Mar 1, 2022 01:24 PM UTC