TCPDF MultiCell ignoring $fitcell parameter when using $ishtml=true - tcpdf

I have a pdf with an area for text to go. The text can sometimes be very long or quite short. TCPDF has a great feature in MultiCell called $fitcell, which adjusts the font size based on the containing cell.
However, this parameter gets ignored when I use $ishtml=true, and it doesn't change the font size, which then goes out of the cell when it gets too long.
I need it to be HTML (to change font colors and bold within the text), but also to be fitted by adjusting the size.
How can I accomplish this?
I have tried using writeHTMLcell, but it doesn't have a $fitcell param.

Related

Is there a way to only draw attributed text on screen?

I'm creating an app that loads a huge amount of text into a UITextView (thousands of lines). Each line is syntax highlighted, so I'm using NSAttributedString to color it. This works fine, but the more text I load, the more processing power, time, and memory it takes to create all the attributed text.
Is there a way to find which lines of text will be on screen and then I can calculate the attributed text for this portion? I believe it would be possible with CoreText but I'd rather use something less raw.

How to get a normalized font size for a PDF using PDFBox

I am working on a project that parses pdf files and extracts text. I am using the TextPosition class to generate a data-structure containing the position and size of each character in the pdf file.
I am running into an issue where there is a custom defined Type 3 font inside the pdf with really large characters. Font that appears to be about font size 9 on the screen are actually set to a font size of 0.24. I attempted to try and use the fontDescriptor to try and get the cap height of the font and use that instead, but it is null. Also, there is another font on the page that has a large amount of white-space above and below it, making the Cap height unusable. Here is what the TextPosition class looks like for a random character on the page.
I was hoping that someone knew how to get the correct pt font size?
Thanks

Change the height of individual characters using core text

I have a font where unfortunately the numbers and letters are different heights. I need to display a reference code which is a mix of letters and numbers and the uneven heights of the characters looks jarring. Is it possible with core text (or another technology on iOS) to render certain characters with a slightly stretched height so that it looks even numbers and letters are displayed together.
E.g i have the string '23Rt59RQ' I need the 2,3,5,9 to be rendered with a larger height.
AFAICT, there's nothing in the CGContext API (which is what you'd want to use for laying out sets of glyphs) which would directly, easily facilitate this.
If it's really very important to use the font you are using, you could make separate calls to CGContextShowGlyphsAtPositions for alphabetic and numeral characters, calling CGContextSetFontSize each time so that the end result ends up matching, but this is a lot of overhead for just drawing text, and will probably result in undesirable performance.
My real advice would be to pick a better font so that this isn't even an issue :)
In the end of used regex to identify the character groups and then created an attributed string varying the font size in the font given in the NSFontAttributeName attribute according to which characters were to be displayed.
Kinda hacky but it had the desired effect.

Word Openxml: how to get a text box the right size?

I'm using PHP to generate docx documents from a database. The generated document contains column charts which have labels attached (i.e. user shapes containing textboxes). In an attempt to get the textboxes to accommodate and display all of the text (i.e. it shouldn't be necessary for the user to resize a textbox to see all the text) my code calculates how many characters will fit into 3cm, adds linefeeds to the string as required and tells me how many lines of text are needed. I have:
<a:xfrm xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
<a:off x="1638276" y="1676399"/>
<a:ext cx="1257325" cy="'.(252000 * $labelLeftLines).'"/>
</a:xfrm>
which I believe should give me a text box around 3.5cm wide (extra .5 for the internal padding) and a height of .7cm multiplied by whatever is the value of $labelLeftLines. However, the text box always turns up as 3.cm wide by .86cm high, which only ever displays one line of text.
If I add in 'autofit':
<a:bodyPr xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" vertOverflow="clip" wrap="square" rtlCol="0">
<a:spAutoFit/>
</a:bodyPr>
the generated file looks just the same, though, when I right click on the textbox to inspect the properties, 'autofit' is indeed applied. I have to uncheck it and recheck it to make it affect the textbox.
Any openXML gurus out there?
Hmm, some random floundering around revealed that the values I need to manipulate are here:
<cdr:relSizeAnchor xmlns:cdr="http://schemas.openxmlformats.org/drawingml/2006/chartDrawing">
<cdr:from>
<cdr:x>0.47</cdr:x>
<cdr:y>0.75</cdr:y>
</cdr:from>
<cdr:to>
<cdr:x>0.67</cdr:x>
<cdr:y>1</cdr:y>
</cdr:to>
Changing those values does actually change the size of the texbox, though I haven't a clue what units are being used. From 0.75 to 1 produces a height of 1.43cm.
One day I'll maybe be able to find my way around the doucmentation.

TextMorph default font size

I'm trying to have an empty TextMorph with a default font size of 12 points, where the original default is 9pts. If I bring up the halo and change the font size to 12pts, the empty TextMorph will still default to 9pts when text is entered into it. I can sort of get around this by putting a space in the TextMorph, then changing the font via the halo to be 12pts. However, this seems rather clunky, and as such was wondering if there might be another way to accomplish this?
thanks.

Resources