TCPDF: changing font size in the header - tcpdf

Is it possible to change the font size of characters in the header? All font settings I've tried only seem to affect the body of the PDF file.

If you are using the default headers, call this before you call the AddPage method.
$pdf->setHeaderFont(array('fontnamehere', 'stylehere', fontsize));
For example, here's one I used with my own project:
$pdf->setHeaderFont(array('playtime', '', 20));
Which set the header to use the regular-styled playtime font (a font I added to my installation) at 20pt. I assume it's points anyway. The array isn't documented anywhere I could find, which is typical of TCPDF documentation. I should note that larger sizes may not fit like you expect, so you can set the content container's top margin to allow more space for a different sized header, like this:
$topheader = 40; //Just an example, new top margin in current TCPDF units.
$pdf->SetMargins(PDF_MARGIN_LEFT, $topheader, PDF_MARGIN_RIGHT);
And I'd like to take a moment again to stress that it should be called before AddPage is called, I learned a hard lesson regarding that myself.
If you want to do more complex headers, you can also write your own Header and Footer methods by extending the class, as in example 3 on the TCPDF site.

Related

Custom iOS keyboard - Custom font output

I am trying to create a custom keyboard using the app keyboard extension. I am happy with the layout but the output is depended on the UITextField's font.
Is there a way to force a different font (use special characters?) while using the keyboard ?
Thank you
It depends.
Text field (or any other view that draws text) uses 2 informations on how to show some text. One is the sequence of characters called String and the other one is how the string should be represented. The second one is then split it things like fonts, colors, line height, line breaking and wrapping...
So the keyboard alone is not enough to for instance present a certain part of word using different fonts. You need at least a bit of access to the item that represents the text. So if you have no access to your text field then the answer is; No, you can not fore a different font when using different keyboard.
If you do have the access then the answer should lie in NSAttributedString. It is a string you can assign to most items under attributedText. This class wraps your raw string and can add many properties to parts of text you want to change. That includes using a different font.
Another approach would be using HTML tags. Again you will need to process this using for instance NSAttributedString or display it with another element like web view.
I would try it with using NSAttributedString. Hook up to delegate and implement textField(: shouldChangeCharactersIn: replacementString:. The implementation itself may still not be easy though.

Positioning dynamic controls dynamically in iOS ViewController

First of all, let me tell you that I am new in Xamarin.
I am facing a problem in rendering controls dynamically on UI.
Approach I am using is: Xamarin.iOS
I have list of Questions having different Question Types
I loop through all questions and render them according to the question type.
Client wants to have HTML in Question Title, so that he can add any type of html tags including images, links etc in HTML. (I cannot use ‘NSAttributedString’ because it doesn’t support all HTML tags)
I am not using AutoLayout
I think UIStackView is a new control which is not available for older versions
Problem is, when I render UIWebView for QuestionTitle, and other control (let us say UITextField) for simple input from user, I do not know about the exact content length of Title (which is HTML) and therefore, I set default height of UIWebView as ‘100’ and once WebView is loaded, I set the height of webview according to the content size height. While rendering control, I calculate the Y-axis for every control to be rendered. When WebView is loaded, its height gets shrunk or expanded according to the size of content and therefore, the preceding sibling’s y-axis remains there since we don’t know how much siblings are there whose y-axis should be adjusted. (Keep in mind we have multiple webviews, as we have more than 1 question).
Is there any way, we can position all controls automatically (Just like we have LinearLayout in Android)?
Is there any better approach I can follow in order to resolve this kind of blocker?
I will really appreciate your help in this problem.

Custom bulleted text in UITextView

I need square bulleted(colored) text as follows
◼︎ Some large amount of text that
make it span to the next line.
to be shown in UITextView. But the problem is it doesn't git the padding on the next line.
◼︎ Some large amount of text that
make it span to the next line.
These bulleted text is of static content and hence no need to set it through code.
Also custom font is not working when I set attributed type. Custom font used is Raleway.
You need to set up a ruler with a "hanging indent." I have no idea how to do this manually with text attributes.
I would suggest instead setting up what you want in a .rtf file and then loading an attributed string from the RTF using either initWithURL:options:documentAttributes:error: (which is only available in iOS 9 or later) or initWithData:options:documentAttributes:error: (which is available in iOS >= 7.0.)
You specify an options dictionary of
Objective-C:
#{NSDocumentTypeDocumentAttribute:NSRTFTextDocumentType}
Swift:
[NSDocumentTypeDocumentAttribute:NSRTFTextDocumentType]

How use different font styles and icon in a Firemonkey stringgrid cell

There seems to be not much information available about this subject so hopefully someone can give some suggestions.
I would like to change color and style of different parts of text in a stringgrid cell.
Example:
20-02-2011 - Document Title
Would it also be possible to show an icon in a stringgrid cell?
It is indeed possible to show icons or bitmaps in a string grid, the Monkey Styler blog includes an example of how to customise cell display in a FMX grid.
http://monkeystyler.com/blog/entry/firemonkey-grid-basics-custom-cells-and-columns
Thinking about the other part of your question though, you will have to build a style up to display text in different fonts, as yet FMX does not have a richtext equivalent or HTML rendering components (I'm sure the latter will come, the former I am not confident on getting for a while!). You would have to have a text component in the style for each different font size/style etc, you would need to name the text elements (using binding or stylename properties) and handle the setting of the text contents using code in the ongetvalue and onsetvalue events (I guess you could also use a onapplystyle event) to display some text in bold and some not.
The event handler would then use either a binding - which is easier to set but - in my experience - buggy;
mycell.binding['boldtext']:='sometext';
Or find a style element by stylename by using findstyleresource;
tempobj:=mycell.findstyleresource('boldtext');
if tempobj is ttext then
ttext(tempobj).text='sometext';
Excuse any bad coding style there, but you get the general idea (I hope) if you set autosize to true for the ttext components in the style and align them left you get - mostly - what you are after. The only issue is that the resulting text doesn't look quite seamless because autosizing and aligning left doesn't really give you the same space between the fonts that you would get with a richtext or HTML display. You should be able to fiddle with the padding (giving it a negative number for the left padding should allow you to remove any extra space) but you have to live with that not being entirely perfect compared to proper font hinting and alignment.

How to set different page properties for the first, even and odd pages using OOXML?

Is there a way, using Open XML SDK, to set different page size, orientation and margins for the first, even an odd pages. I know how to set different headers and footers for the first, even, and odd pages but I can't figure out how to set different first even and odd page properties (size, margin, orientation) .
Regards.
You can't. Those properties are set at the section level, and sectPr elements are attached to specific paragraphs. They apply to everything in the section (not just odd pages for example).
You can of course set page properties for specific pages, by making a section out of them, but this requires hard coded page breaks / section breaks before and after.

Resources