I'm currently trying to implement Page numbers in the footer of PDFs using PDFXChange Core API version 7.0.0327.1 using the following code. Is there way to get the number to start at 1? Currently with the current code below the first page shows 2 of ? and not 1 of ? so %[Page] is getting replaced with a 2 on the first page causing the last page to have 16 of 15 for example.
Public Shared Sub AddHeaderAndFooter(ByVal PDF As IPXC_Document, ByVal DestinationPDF As String)
Dim m_pxcInst As New PXC_Inst
Try
m_pxcInst.Init(g_RegKey)
Dim auxInst = CType(m_pxcInst.GetExtension("AUX"), IAUX_Inst)
Dim firstHeaderFooter = m_pxcInst.CreateHeaderAndFooterParams()
Dim font = PDF.CreateNewFont("Arial", CUInt(PXC_CreateFontFlags.CreateFont_Serif), 400)
Dim fillColor As IColor = auxInst.CreateColor(ColorType.ColorType_RGB)
fillColor.SetRGB(0, 0, 0)
firstHeaderFooter.Font = font
firstHeaderFooter.FillColor = fillColor
firstHeaderFooter.CenterFooterText = "%[Page] of %[Pages] %[Date:MM.dd.yyyy] %[Time]"
firstHeaderFooter.BottomMargin = 30.0F
firstHeaderFooter.TopMargin = 36.0F
firstHeaderFooter.RightMargin = 36.0F
firstHeaderFooter.LeftMargin = 36.0F
firstHeaderFooter.FontSize = 10.0F
Dim pages As IPXC_Pages
pages = PDF.Pages
Dim bitset As IBitSet = auxInst.CreateBitSet(CUInt(pages.Count))
bitset.Set(0, CUInt(pages.Count))
PDF.PlaceHeadersAndFooters(bitset, firstHeaderFooter)
PDF.WriteToFile(DestinationPDF)
PDF.Close()
Catch ex As Exception
MsgBox("AddHeaderAndFooter Error: " & ex.Message)
Finally
Try
m_pxcInst.Finalize()
Catch
End Try
End Try
End Sub
Page number in Header/Footer starts at 2
Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan
Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.
When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.
When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
- Vasyl-Tracker Dev Team
- Site Admin
- Posts: 2353
- Joined: Thu Jun 30, 2005 4:11 pm
- Location: Canada
Re: Page number in Header/Footer starts at 2
Hi mmanuel.
Sorry for delay with the answer. Try to use this workaround:
firstHeaderFooter.Start = 0
Cheers.
Sorry for delay with the answer. Try to use this workaround:
firstHeaderFooter.Start = 0
Cheers.
Vasyl Yaremyn
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.