Question is quite simple but unfortunately, i am not able to find solution.
I am trying to add watermark in pdf page. here is the code.
$mpdf->SetDisplayMode('fullpage');
$mpdf->SetWatermarkText('DRAFT');
$mpdf->watermarkTextAlpha = 0.081;
$mpdf->watermark_font = 'DejaVuSansCondensed';
$mpdf->showWatermarkText = true;
$mpdf->WriteHTML($html);
Above code work fine but size of Watermark is quite big.
I want to make it smaller.
I read the documentation but didn't found fontsize for watermark.
I set the watermark fontsize by modifying watermark function in mpdf.php:
Example:
function watermark($texte, $angle = 45, $fontsize = 120, $alpha = 0.2) {
$fontsize = 24
}
Related
How to rotate SmartArtNode text aspose.slide
I use:
tmNode.TextFrame.TextFrameFormat.RotationAngle = 90
But it's not working
I have observed your requirements and suggest you to please try using Aspose.Slides for.NET 17.1.0 using following sample code. I am able to observe the rotation effect on text. I hope this will be helpful. You may also contact us in Aspose.Slides forums if there is any further inquiry.
using (Presentation presentation = new Presentation())
{
// Accessing the slide
ISlide slide = presentation.Slides[0];
// Adding SmartArt shape and nodes
var chevron = slide.Shapes.AddSmartArt(10, 10, 800, 60, SmartArtLayoutType.ClosedChevronProcess);
var node = chevron.AllNodes.AddNode();
node.TextFrame.Text = "Some text";
node.TextFrame.TextFrameFormat.RotationAngle = 90;
// Saving Presentation
presentation.Save(dataDir + "FillFormat_SmartArt_ShapeNode_out.pptx", SaveFormat.Pptx);
}
I work with Aspose as Developer evangelist.
I am trying to add dynamic labels on groupbox, but my text size which I also created dynamically is only showing half of it on group box.
This is my simple code:
private void AddLabels()
{
List<Label> labels = new List<Label>();
groupBox1.Controls.Clear();
Label l = new Label();
l.Font = new Font(new FontFamily(System.Drawing.Text.GenericFontFamilies.Serif), 30, FontStyle.Bold);
l.Text = "Hello World";
l.Parent = groupBox1;
l.BringToFront();
labels.Add(l);
}
As you notice on my code, my Font Size is 30, but when I run this, only "Hello" text is showing and only half of "Hello" is showing. The word "World" is not showing also.
Just in case you encounter the same problem. I already figured it the day I posted my question and I want to answer this just in case someone is looking for an answer.
Just adjust your label font size and everything will work fine.
Can anyone help me I'm not having much luck
I want to try workout the ideal fontsize for my text based on the width of an image it's overlaying and the amount of characters in the text string.
could anyone help me with the formula for this.
I got it semi-working but only due to the Infinite monkey theorem!
// gets text1 count
$charcount = strlen($line1);
// gets text1 size from count
$newsize = ($width / floor($charcount));
$add = ( 20 % $newsize );
$newsize = ($newsize + $add);
// Changes Font Size
$text1->setFontSize( $newsize );
I use something like this based on the width or height of your image:
resize_font = function () {
// then play around with the denominator until the font is the size you want
var fontSize = parseInt($("#your_image_div").width()) / 2 + "%";
//then apply that to your css for that text div element
$(".your_text_class").css('font-size', fontsize);
};
// then hook it to whatever event you want to
$(document).ready(resize);
Hope this helps. This trick is handy for making elements resize in relation to the veiwport too. Hope it helps.
Code sample:
var headerRowBackground:RGBColor = new RGBColor(0);
headerRowBackground.b = 58;
headerRowBackground.g = 28;
headerRowBackground.r = 255;
printPDF.beginFill(headerRowBackground);
printPDF.addCell(30, 20, "Room");
The word "Room" is in red, as is the rest of the text in the PDF. I actually want to make the cell background colour red. Anybody know why this doesn't work?
You should look at the API more:
printPDF.addCell(30, 20, 'Room', 0, 0, '1', 0xFF0000);
The documentation is wrong, the fill parameter is described as "Link can be internal to do document level navigation (InternalLink) or external (HTTPLink)".
The code to get this working is:
printPDF.beginFill(new RGBColor(0xFF0718));
printPDF.textStyle(new RGBColor(0x000000));
printPDF.addCell(30, 10, "Room", 0, 0, Align.LEFT, 1);
A couple of things about the code:
The fill parameter should be 0 or 1
rather than the fill value. It just
either switches on or off the fill
value previously set.
The text style
should be set too otherwise the text
and background will use the same
colour
I am trying to have text automatically size its font to fill an entire text component.
My current approach is to set font size as a function of the number of text characters and the text components height and width but I can't find the right coefficients to make this work nicely.
Is there a simpler or more elegant way?
Does truncateToFit work on Text? I read somewhere that it doesn't work well.
Edit: I forgot to mention that I would like it to scale beyond the max font size (which is 127 i believe). How is this done? scaleX?
AS3 sample function. You should call it anytime your TextField's content changes
function Autosize(txt:TextField):void
{
//You set this according to your TextField's dimensions
var maxTextWidth:int = 145;
var maxTextHeight:int = 30;
var f:TextFormat = txt.getTextFormat();
//decrease font size until the text fits
while (txt.textWidth > maxTextWidth || txt.textHeight > maxTextHeight) {
f.size = int(f.size) - 1;
txt.setTextFormat(f);
}
}