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

  • Home
  • SEARCH
  • 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 8330179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:02:33+00:00 2026-06-09T02:02:33+00:00

I have been trying to create a PDF containing a SVG image with the

  • 0

I have been trying to create a PDF containing a SVG image with the TCPDF Library. I wanted to have the SVG centered on a page with some text above and below it.

I have managed to get this working to a point however part of the SVG image is being cut off, it seems to have something to do with the X/Y position but I am not sure how to correct this problem.

What is causing the TCPDF Library error that cuts off my SVG image?

Code:

<?php 

require_once('../../TCPDF/tcpdf.php');

// Remove the default header and footer
class PDF extends TCPDF { 
    public function Header() {} 
    public function Footer() {} 
} 

$pdf = new PDF();

$pdf->AddPage();

$pdf->SetFont('helvetica', 'B', 160);

$pdf->SetTextColor(0,0,0);

$pdf->Cell(0, 0, 'Higher', 1, 1, 'C', false, '', 1);

$pdf->Ln(4);

$pdf->ImageSVG($file='Image.svg', $x=0, $y=80, $w=100, $h=100, $link='', $align='N', $palign='C', $border=1, $fitonpage=false);

$pdf->Ln(4);

$pdf->Cell(0, 0, 'Lower', 1, 1, 'C', 0, '', 1);

$file = 'Result' . '.pdf'; // Set the name of the PDF file

$pdf->Output($file, 'F'); // Save PDF to file

$pdf->Output($file, 'I'); // Display the PDF

?>
  • 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-09T02:02:34+00:00Added an answer on June 9, 2026 at 2:02 am

    This seems to a bug with the current version of the TCPDF Library that I was using.

    The problem is when you use the align features:

    $align='N', $palign='C'
    

    etc, and if anyone else has a similar problem and needs a workaround for it I fixed it by manually centering the SVG using the x/y positions.

    Another problem to note is when I tried using some SVG images that were in large size I noticed it would create visual glitches so the SVG handling definitely seems to have a few bug. For that problem the workaround I found was to lower the size of the SVG and then scale them using the width/height values instead which seemed to correct the problem.

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

Sidebar

Related Questions

I have been trying to create an image from PDF using c#, I have
I have been trying to create an XML using the simplexml library (v2.6.2) http://simple.sourceforge.net/home.php
We're trying to create a .NET aspx page that will have a PDF within
I have been trying to create some dynamic Xaml. I have the following c#
I have been trying to create a HTML E-mail, which is just one image
I have been trying to create an array of a class containing two values,
I have been trying to create a slide left effect to display my page
I have been trying to create a web service out some python scripts, and
I have been trying to create a page using views that will list down
I have been trying to create LI elements with float left and an image

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.