Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9062743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:48:50+00:00 2026-06-16T15:48:50+00:00

I am using TCPDF and specifically the ImageSVG() function to put some text in

  • 0

I am using TCPDF and specifically the ImageSVG() function to put some text in a box. I am attempting to make it right justified, but I can’t seem to get it right. I also need it to stretch the text inside so that it fits the containing rectangle. So far I have this code:

$pdf->ImageSVG('@<svg width="'.$line4_w.'px" height="'.$line4_h.'px" version="1.1"
     viewBox="0 0 '.$line4_w.' '.$line4_h.'" preserveAspectRatio="none"
     xmlns="http://www.w3.org/2000/svg">
  <rect x="0" y="0" width="'.$line4_w.'" height="'.$line4_h.'" 
        fill="'.$bgcolor.'" />
  <!-- A text string that spans most of the viewport -->
  <text x="40" y="50" font-size="40" font-family="Verdana" style="fill:'.$color_select_text_main.'" >'.$content.'</text>
</svg>', $x=$line4_x+$text_x, $y=$line4_y, 0, 0, $svgLink = '', $svgAlign = 'R', $svgPalign = '', $svgBorder = 0, $svgFits = true);

The width and the Height values are variable, and so is the content string.

I have used the code from here as a starting point:

http://www.w3.org/TR/SVG/coords.html#ExampleViewBox

But my problem is basically when I change the string length of $content to deliberately overflow the container, the text isn’t shrunk at all, and the remaining text is just cut off.

Regarding the justification, I have tried to use the text-anchor attribute (of the text element), setting it to end, and it basically seemed to just put it completely outside of the viewport.

What am I doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T15:48:51+00:00Added an answer on June 16, 2026 at 3:48 pm

    I’m pretty sure that my solution isn’t the most efficient, but I abandoned this approach, made the image with ImageMagick and then just used the Image() capability of TCPDF.

    ImageMagick’s convert and label functionality is really capable of doing more than what I need for the positioning and rendering of the text. Not sure if this question is worth keeping around, but perhaps it will help someone in the future.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using TCPDF in CakePHP and trying to make some background (grey) for few
Im using latest TCPDF version(5.9). But have some strange problems with encoding. I need
I'm using tcpdf ( http://www.tcpdf.org/ ) to generate PDFs of some tables and images.
I'm using TCPDF for generating dynamic PDFs. It works fine but since I move
I'm using TCPDF class to generate PDF. First I send some data in json
I am using TCPDF, but i encountered these problem. please give me solution. A
Im using TCPDF for the first time and am laying out some data using
I am working my way through implementing a report generation solution using TCPDF. Some
I'm using TCPDF to generate a PDF with text only. First I've used multiCell
I am using TCPDF's writeHtml function for a page that renders properly in the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.