Rank: Newbie Groups: Member
Joined: 8/6/2021 Posts: 5
|
Hallo EO.PDF Team,
I have a question, I would like to load sections of text into a PDF that contains a template as a background. It works very well on the first page, from the second page on I get an empty PDF with the text. How can I set the PDF template for each page?
Greetings from Germany Bernhard
Dim doc As New PdfDocument(App.path+"\PDFMERGE\PDF_DRV_BERICHT\PDF_MERGE_BLATT1A1.PDF")
'Set the document information doc.Info.Title = "EO.Pdf Sample PDF file" doc.Info.Creator = "EO.Pdf Library" doc.Info.Author = "EO.Pdf"
'Hide the toolbar doc.ViewerPreference.HideToolbar = True
Dim lay As New AcmPageLayout(New SizeF(8.2, 11.69), New AcmPadding(1, 1.57, 0.5, 1))
'Create a new AcmRender object Dim render As New AcmRender(doc, lay) doc.Fields("PNAME").Value = "Peter Mustermann"
Dim Text(20) As AcmText Dim Titel(20) As AcmText
'Create a new text object For x As Integer = 0 To 20
Titel(x) = New AcmText("That is title nr." + x.ToString) Titel(x).Style.FontStyle = FontStyle.Bold Text(x) = New AcmText("Lorem Ypsum.") Text(x).Style.ForegroundColor = Color.Black render.Render(Titel(x)) render.Render(Text(x))
Next x MsgBox(doc.Pages.Count.ToString) 'Save the result doc.Save("d:\test.pdf")
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi, If your template PDF file is only one page, then you must expand it to the exact number of pages as your output. So for example, if your final output is 3 pages, then you must expand your template PDF file to 3 pages first. You can use PdfDocument.Merge to merge the file into 3 pages:
Code: Visual Basic.NET
Dim docs(3) As PdfDocument
For i As Integer = 0 To docs.Length - 1
docs(i) = New PdfDocument(template_file_path)
Next
Dim template As PdfDocument = PdfDocument.Merge(docs)
After that you can use AcmRender to render into template. If you do not know exactly how many pages your result will be, you can run your rendering code twice --- the first time to get how many pages you have. The second time uses the correct template. Hope this helps. Please feel free to let us know if you have any questions. Thanks!
|
Rank: Newbie Groups: Member
Joined: 8/6/2021 Posts: 5
|
Thank YOU!!!!
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
You are welcome. Please feel free to let us know if there is anything else.
|