Can I make page-unique headers/footers in MS Word? - vba

I'm writing VBA to process MS Word documents, and I need it to examine the contents of individual pages and generate related header/footer text from that. Is there a way to do this without creating new Sections?
I need the document to flow as it should, unbroken by Sections, but I also need (some of) the header/footer text to be distinct, per page. I know this is unusual due to auto-flowing pagination, etc. But, it really is necessary in this case; pieces of the header/footer must tie directly to each page's contents. That said, it may not be mandatory to have the text actually inside the "proper" header/footer; but, I do need the end result to be to that same effect.
Any tips? Can headers/footers be used for this? (In my research, it appears they may not be able to, although I may be missing something. Any other tips, if not? Perhaps some sort of special field/box?)
Note: Obviously, running this code would be a final step (once the document is in final form) since any editing of the document would re-flow its layout, modifying page contents.

If you don't want to use sections, you can use conditional IF fields like this:
{IF { PAGE } = 2 "Second Page" "Other Page" }
Note that you need to create nested fields for that, e.g. by pressing Ctrl+F9.

Related

Is it possible to use variables in a PDF document?

I want to make a editable PDF document – but I want to take it a step further.
Is it possible to create some editable fields on the first page where the user can put in personal information (name, age etc.) and have the document fill itself in where "name" is required?
I need this for some employment contracts and it would be alot faster if the user only needs to fill the information in once, print the PDF and sign it. :)
In PDF a single form field may have multiple widgets. By definition all these widgets have the same content.
E.g. have a look at thie sample document aFieldTwice.pdf. You see two fields. As soon as you edit one of them and press enter, the same content occurs in the other one.
This might be what you look for.

VBA word doc - Show different items based on selection

I'm trying to reduce the size of a form, so I want to hide and show sections based on input.
It's not efficient to program in all of the items I need to show,
I've already written more than 100 lines for one page and there are
eighteen pages total. The pages contain a mix of Tables, images,
paragraphs, and ActiveX object (textbox, combobox, etc)
.
I was looking around and there was a hidden method that existed for
tables previously. But I tried it and found out that it doesn't work
for Word-2010. Are there any replacements for this?
My thoughts
Right now the only thing I can think of is putting unique IDs all over the file, when I need to replace one with a table I can search for the UID and get its range then insert the table there. CONS: Believe me, it'll take a week at best. This also doesn't deal with images and leaves annoying UID's in plain sight of the user. I think Any other solution is better than this.
I'm hoping there is an object I can put everything in, then hide it.
Is there a way to do this?

Possible to control PDF layout with iText?

I'm writing some logic to build a large single PDF file that our users can print at their convenience. I'm using Java's iText library (through Clojure's clj-pdf).
I'm trying to have the PDF show the same exact template form on every single page, however I can't seem to find any documentation or indication that one can have PDF content "fit to a page".
The text in these forms varies a little bit, so there's a chance it might require more of fewer text lines per page. This means that the content has a chance of spilling over to the next page, or being too short, making the next page creep up into the previous one, breaking the requirement of "one form per page" for the rest of the document.
I'm trying to figure out if my option is pretty much only to manually check the length of the text on each page and potentially crop it by hand if I goes over n lines, or if the PDF format somehow supports a smart way of having paragraphs+tables+headings all fit in one page. Some UI systems allow you to control how spill-over is handled, anywhere from cropping to resizing the font, so I'm curious if PDF supports anything of that sort.
Edit: ended up going with pagebreaks for simplicity, wasn't aware of that option when I wrote this question.
If you want to take control over the space taken by text, for instance to fit it on a single page, the way to go would be to create a ColumnText object and to add the content in simulation mode. If the text fits the page, add it for real. If it doesn't, use a smaller font size. This is demonstrated in the MovieAds example where snippets of text are fitted into AcroForm fields.

How to create switchable multi-language pdf form?

I want to create a pdf form for two language (Chinese/English) UI, and there's a button(s) or somethings on the form for language switch, is there anyway can make it? and how to do?
thanks!
Thanks for all reply!
Actually I got a sample like this,
PDF Sample
there're two checkbox on the top-left of the form, one is for English UI, the other is Chinese, I just want to know how to make PDF like that sample? (and I don't see any layers on the sample...)
thx
mkl's comment (which he should turn into a full answer, really) already hinted at the option to use different page templates residing in the same file.
Another option you could explore is this:
put the two language versions into 2 different layers (or 'optional content groups' in PDF parlance)
make the visibility of the two layers toggeable
let the user activate that layer which he/she needs.
Layer activation can be handled through normal Acrobat Reader user interface elements.
The layer switching can be made accessible via a "button" on the PDF page too -- but that requires additional JavaScript to be embedded in the PDF (something many people are not particularly keen about).
As Kurt proposed, I make my comment on Frank's answer an answer in its own right:
Actually there is a pdf feature seldomly used nowerdays, page
templates. Thus, those two forms can reside in the same file in
different page templates, and based on some initially present buttons
("English version", ...) the desired form is spawned.
Unfortunately I don't know how to create page templates using some easy-to-use tool, I only came a cross them in the context of integrated PDF signatures (depending on the signature type, page template instantiation is a document change not breaking the signature) and tested them with low-level tools.
Essentially page templates are PDF objects just like page dictionaries of the normal pages, they are not XFA stuff. They merely are not referenced in the pages tree but instead in the name tree.
There is a JavaScript command which creates a visible page based on such a template --- I don't know which anymore; I may be able to find out when I'm back in office next week. This command would have to be bound to the inital language selection button in the file.
The problem will be in switching the static text - PDF does not allow this.
If I were you, I would split the document into two identical forms in the respective languages. You can use bookmarks and links on the first page to navigate to the right part of the document.
Note that it is possible to assign the same field names to the Enlgish/Chinese versions of your fields. This will make it easier to process the submitted form data because the process path would be independent of the chosen language. It will also simplify any JavaScript (validation, summing, etc.) you plan to add.

Drupal print module: controlling layout in PDF files?

Using the print module and tcpdf I'm trying to fix the layout of the PDF files for a specific content type. I'm messing around in the tpl.php file and can't find a way to modify individual fields. There's just the massive $print['content'] variable that contains all of the page content. So, is there a way to access each field?
Basically I want full control over how fields (their labels, data, etc) are displayed. Currently, they are displayed like inline elements, one after the other. This looks pretty ugly.
When you edit a "View" you will notice a link that says "Theme: Information" it retrieves all suggested tpl's for the whole $output and also for each of the fields.