PlaceHeadersAndFooters Method

A forum for questions or concerns related to the PDF-XChange Core API SDK

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.
Post Reply
VB_Tester
User
Posts: 6
Joined: Thu Oct 01, 2015 12:40 pm

PlaceHeadersAndFooters Method

Post by VB_Tester »

Hello Tracker -Team!

I was able to place a watermark on PDF as described in the code sample on this page here: https://sdkhelp.pdf-xchange.com/vie ... eWatermark
BUT what we initially wanted/needed to do was placing HeadersAndFooters on PDF (like https://sdkhelp.pdf-xchange.com/vie ... AndFooters)

So i took the code from your watermarks sample and changed everything according to headersAndFooters:

Dim strpath As String
Dim gInst As New PXC_Inst
Dim pDoc As IPXC_Document
Dim pAInt As IAUX_Inst
Dim intCount As Integer
Dim pIndex As IBitSet
Dim kfz As IPXC_HeaderAndFooterParams

strpath = "D:\MyPDF.pdf"
Set pDoc = OpenDocumentFromFileSample(strpath, gInst)
intCount = pDoc.Pages.count

Set pAInt = gInst.GetExtension("AUX")
Set pIndex = pAInt.CreateBitSet(intCount)
Call pIndex.Set(0, intCount)

>>>>>It seems there is something missing like a "Inst.CreateHeaderFooterParams();" method as it exists with the watermark: "Inst.CreateWatermarkParams();" here<<<<
>>>>>Set kfz = gInst.CreateHeaderFooterParams()<<<<<<

kfz.FontName = "Source Code Pro"
kfz.FontSize = 14
kfz.RightHeaderText = "My New Header Text"
kfz.TopMargin = 8.5
kfz.RightMargin = 8.5
Call pDoc.PlaceHeadersAndFooters(pIndex, kfz)

strpath = "D:\NewFile.pdf"
pDoc.WriteToFile strpath

Perhaps you can add a code sample on this page https://sdkhelp.pdf-xchange.com/vie ... AndFooters like you did with the watermarks here https://sdkhelp.pdf-xchange.com/vie ... eWatermark?

We are using the Core API SDK by the way. Maybe Headers and Footers is not available in Core-SDK but only in Editor-SDK?

Many thanks in advance!
Last edited by VB_Tester on Mon Jun 06, 2016 3:30 pm, edited 1 time in total.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: PlaceHeadersAndFooters Method

Post by Sasha - Tracker Dev Team »

Hello VB_Tester,

The method you require was indeed missing. The method CreateHeaderAndFooterParams will be available from the next build.
Meanwhile, we've uploaded a developer build with that method included that you can try using before the official release.
The link to the latest developer build can be obtained here:
https://forum.pdf-xchange.com/ ... 49#p101349

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
VB_Tester
User
Posts: 6
Joined: Thu Oct 01, 2015 12:40 pm

Re: PlaceHeadersAndFooters Method

Post by VB_Tester »

Hello Alex!

Well, the Method "CreateHeaderAndFooterParams" works fine now, code compiles - all gut - but i am running into another "funny issue".

My newly createt testfile.pdf seems untouched - no Header or Footer visible BUT if I open the pdf file with PDFxChangeEditor and navigate to Documents/Headers-Footers/- I think its called manage - there is a new entry with #1 and date/time with al my Information in it. Only thing is: its not visibel on Screen unless i click "edit" and then "ok" in previusely mentioned menue.

Set kfz = gInst.CreateHeaderAndFooterParams
kfz.FontName = "Source Code Pro"
kfz.FontSize = 10
kfz.RightHeaderText = "My_New_Header_Footer_Test_Text"
kfz.TopMargin = 20
kfz.RightMargin = 20
kfz.LeftMargin = 20
kfz.BottomMargin = 20
Call pDoc.PlaceHeadersAndFooters(pIndex, kfz)

strpath = "D:\testfile.pdf"
pDoc.WriteToFile strpath

Seems in code I am missing something like "headerFooter visible" or similar.

Strange thing is: with watermarks everything worked fine right from the start - they are visible at once when i Open the PDF-File - along with the Tracker-Software Water marks in every corner of the sheet.

Has this something to do with "not jet fully implementet HeaderFooter thingie" or am I missing some line of code here?
Many thanx in advance!!!
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: PlaceHeadersAndFooters Method

Post by Sasha - Tracker Dev Team »

Hello VB_Tester,

I've tested this behavior and found out that the header was added though the color was not specified and it appeared blank. For the correct appearance of the header you'll need to do this:

Code: Select all

kfz.FillColor = uiInst.CreateColor(); //Here the IUIX_Inst should be used you can get it by using the GetExtension("UIX") method
kfz.FillColor.SetRGB(0, 0, 0);
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
VB_Tester
User
Posts: 6
Joined: Thu Oct 01, 2015 12:40 pm

Re: PlaceHeadersAndFooters Method

Post by VB_Tester »

Hello Alex!

I assume you mean:

Dim uiInst As IUIX_Inst
Set uiInst = gInst.GetExtension("UIX")

simmilar to:

Dim pAInt As IAUX_Inst
Set pAInt = gInst.GetExtension("AUX")

This leaves me with an error message: "IUIX_Inst - type not defined" error message.

In Online Documentation I found out GetExtension("UIX") is available only in Editor not in Core SDK.
Will it be added to the Core SDK or do we need to swich to Editor SDK for the future?

Sorry to bother you again :-(
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: PlaceHeadersAndFooters Method

Post by Sasha - Tracker Dev Team »

My bad, the UIX instance is not needed here - the FillColor will be already created when the HaF parameters are created.
So you only need the:

Code: Select all

kfz.FillColor.SetRGB(0, 0, 0);
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
VB_Tester
User
Posts: 6
Joined: Thu Oct 01, 2015 12:40 pm

Re: PlaceHeadersAndFooters Method

Post by VB_Tester »

Yep, now it works!
Many thanks to you, thread can be closed.
Cheers to you Alex!
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: PlaceHeadersAndFooters Method

Post by Sasha - Tracker Dev Team »

Glad that worked for you :wink:
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply