What you wrote doesn't work for my use case because there are other things on the page that can't be scaled down. It's not just the table.
Here is my use case:
I have an existing PDF with a letterhead.
My goal is to to open the existing file, add a letter with several paragraphs, add a table of data.
Save it as another file.
Issue with adding the table in this way is that on the second page no margins are used.
Issue with doing it as you suggested, is that the letterhead and letter also get scaled down, not just the table.
I tried a third approach. Create a new doc and page with margins and use DrawTemplate to copy the letterhead from the pageTemplate to the page I'm using.
And then write my letter and table.
- Code: Select all
page.Canvas.DrawTemplate(pageTemplate.CreateTemplate, PointF.Empty)
This worked for the letter and table, but the margins are affecting the letterhead.
Here is the code snippet I'm using for this.
- Code: Select all
Dim doc As New PdfDocument
Dim page As PdfPageBase
Dim docTemplate As New PdfDocument
Dim pageTemplate As PdfPageBase
Dim m As New PdfMargins
m.Top = 36
m.Bottom = 36
m.Left = 36
m.Right = 36
page = doc.Pages.Add(New SizeF(PageWidth, PageHeight), m)
'get template
docTemplate.LoadFromFile(Template)
pageTemplate = docTemplate.Pages(0)
'copy letterhead to page
page.Canvas.DrawTemplate(pageTemplate.CreateTemplate, PointF.Empty)
'code proceeds to write the letter and insert the table...
So the question now is: is there a way to use DrawTemplate to copy the entire contents from one page to another and
not get affected by the margins?
If there isn't a way, what is the correct way of accomplishing what I'm trying to achieve.
Thanks again for the help.