We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Writing to an existing PDF

Thread ID:





88428 Jul 22,2009 03:20 PM UTC Jul 23,2009 06:53 AM UTC WinForms 1
Tags: PDF
Jeff Dressing
Asked On July 22, 2009 03:20 PM UTC

I am trying to just write to an existing PDF. I don''t want to send a formula to it, I just want to physically write the page number as I will be merging all the pages together and I am building a Table of Contents.

I have tried writing it to a fixed location and I have tried determining the page width & height, then putting it where I want it. Neither seem to work.

So I have 2 questions here:
* Am I using the right logic to determine the page height and width?
* What I am doing wrong that is not writing any text to the existing PDF?

Here is the code snippet that is simplified as an example:

Private WithEvents mobjPDFDoc As PdfLoadedDocument
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 10.0F, PdfFontStyle.Regular)
Dim brush As PdfBrush = New PdfSolidBrush(Color.Black)

mobjPDFDoc = New PdfLoadedDocument(strFile)

For intPage = 0 to mobjPDFDoc.Pages.Count - 1
dblHeight = mobjPDFDoc.Pages(intPage).Graphics.ClientSize.Height
dblWidth = mobjPDFDoc.Pages(intPage).Graphics.ClientSize.Width

'I have tried this... This is ultimately what I want to do, I want to put the page number at the bottom right corner of the page.
mobjPDFDoc.Pages(intPage).Graphics.DrawString( _
"Page " & CStr(intPage + 1), font, brush _
, New PointF(dblWidth - 220, dblHeight - 100))

'And I have tried this... and it doesn''t work either
mobjPDFDoc.Pages(intPage).Graphics.DrawString( _
"Page " & CStr(intPage + 1), font, brush _
, New PointF(20, 20))



All of the samples that come with Syncfusion are with NEW documents which are using the PDFDocument object ...I need it to work with an existing PDF that came from somewhere else. I need to use PdfLoadedDocument for an existing PDF. Is this assumption correct? I did not see a way to load an existing PDF to the PDFDocument object.

I cannot get the graphics.Drawstring to write correctly on the PDFLoadedDocument object.


Thiruvenkadam E [Syncfusion]
Replied On July 23, 2009 06:53 AM UTC

Hi Jeff,

Thanks you for your interest in Syncfusion products.

Here is the answers for your questions,

1. Am I using the right logic to determine the page height and width?

Yes ,You have used the correct logic to determine the page height and width.

We can also determine the page height and width by using document.Pages[0].Size.Height and document.Pages[0].Size.Width properties.

Kindly refer the below code snippet which helps another way to determine the page height and width.

//Load the existing document.
Dim PDFDoc As PdfLoadedDocument =New PdfLoadedDocument(@"..\..\Data\Template.pdf");

//Gets the height of the page.
Dim height As Single = document.Pages[0].Size.Height;

//Gets the width of the page.
Dim width As Single = document.Pages[0].Size..Width;

2. What I am doing wrong that is not writing any text to the existing PDF?

I am afraid that I was not able reproduce the mentioned issue "Write text to existing PDF is not showing up".

Please do find the sample from the below specified location which demonstrates how to write the text in to the existing PDF.


Please have a look at the above sample and if still the issue exists,

Could you please try to reproducing it in the above samples or send us pdf documents so that we could sort out the cause of the issue and provide you a solution?

3. Usage of the PdfDocument and PdfLoadedDocument classes ?

PdfDocument Class:

Essential PDF''S PdfDocument class is used to create a new pdf documents.

PdfLoadedDocument Class:

Essential PDF''S PdfLoadedDocument class is represents a logic to handle the existing pdf documents.

Could you please refer the following link if you need more information about the PdfDocument and PdfLoadedDocument classes.





This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon