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 725959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:23:49+00:00 2026-05-14T06:23:49+00:00

i have written the following code: As you can see there is a for

  • 0

i have written the following code:
As you can see there is a for loop to go through some values and display them in the generated pdf. The problem is that all the values are being written at the same place.
I have tried to insert a new line but it does not seem to work. Can anyone suggest me how i can do it? Do i need to write a nested for loop so that it the values at different y positions?

$pdf = pdf_new();

            // open a file
            pdf_open_file($pdf, "C:/xampp/htdocs/final/6.pdf");
            pdf_set_info($pdf, "Author", "");
            pdf_set_info($pdf, "Title", "");
            pdf_set_info($pdf, "Creator", "");
            pdf_set_info($pdf, "Subject", "");
            // start a new page (A4)
            $x = 595;
            $y = 842;
            pdf_begin_page($pdf, $x, $y);
            pdf_set_parameter($pdf, 'FontOutline', 'Arial=c:\windows\fonts\arial.ttf');
            pdf_setcolor($pdf, "stroke", "rgb", 0, 0, 0, 1.0);

            // get and use a font object
            $font = pdf_findfont($pdf, "Arial", "host", 1);

            pdf_setfont($pdf, $font, 10);

            // print text
            pdf_show_xy($pdf, "QUOTATION" , 250, $y - 60);
            pdf_show_xy($pdf, "Customer Name: " . $this->customer_details['first_name'] .
                " " . $this->customer_details['last_name'], 50, 770);
            pdf_show_xy($pdf, "Date: " . date("F j, Y, g:i a"), 50, 750);
            pdf_show_xy($pdf, "Number of items requested: " . $count_items_req, 50, 730);
            pdf_show_xy($pdf, "Number of items found: " . $count_items_found, 50, 710);


            // add an image under the text
            $image = $image = PDF_load_image($pdf, "png",
                "C:/xampp/htdocs/final/images/footer_logo.png", "");

            PDF_fit_image($pdf, $image, 50, 785, "");
            pdf_moveto($pdf, 20, 780);
            pdf_lineto($pdf, 575, 780);
            pdf_stroke($pdf);

            // draw another line near the bottom of the page
            pdf_moveto($pdf, 20, 50);
            pdf_lineto($pdf, 575, 50);
            pdf_stroke($pdf);

            //Draw the lines
            $offset = 184;
            $i = 0;
            pdf_moveto($pdf, 20, $y - 160);
            pdf_lineto($pdf, $x - 20, $y - 160);
            pdf_stroke($pdf);

            pdf_moveto($pdf, $x - 400, $y - 160);
            pdf_lineto($pdf, $x - 400, 80);
            pdf_stroke($pdf);

            pdf_moveto($pdf, $x - 200, $y - 160);
            pdf_lineto($pdf, $x - 200, 80);
            pdf_stroke($pdf);

            pdf_moveto($pdf, $x - 100, $y - 160);
            pdf_lineto($pdf, $x - 100, 80);
            pdf_stroke($pdf);

            pdf_continue_text($pdf, '');
            pdf_continue_text($pdf, '');

            pdf_show_xy($pdf, "Searched Item", 70, $y - 150);
            pdf_show_xy($pdf, "Searched Item", 70, $y - 150);


            pdf_show_xy($pdf, "Item name", 240, $y - 150);
            pdf_show_xy($pdf, "Item name", 240, $y - 150);
            pdf_show_xy($pdf, "Price", $x - 180, $y - 150);
            pdf_show_xy($pdf, "Price", $x - 180, $y - 150);
            pdf_show_xy($pdf, "Discounted Price", $x - 100, $y - 150);
            pdf_show_xy($pdf, "Discounted Price", $x - 100, $y - 150);
            for ($i = 0; $i < count($this->quotation_details); $i++)
            {

                 pdf_show_xy($pdf, $this->quotation_details[$i]['name_searched'] , 70, $y - 500);

            }


            // and write some text under it
            pdf_show_xy($pdf, "", 250, 35);


            // end page
            pdf_end_page($pdf);

            // close and save file
            pdf_close($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-05-14T06:23:50+00:00Added an answer on May 14, 2026 at 6:23 am

    You don’t need a nested loop, you just need to change the value you subtract from $y each time. You can do it like so:

    
    $placeholder = 500; // initial value
    for ($i = 0; $i quotation_details); $i++)
    {
      pdf_show_xy($pdf, $this->quotation_details[$i]['name_searched'] , 70, $y - $placeholder);
      $placeholder = $placeholder - 20;
    }
    

    You might want to subtract by more or less than 20. Play around and find a value that looks good.

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

Sidebar

Related Questions

I have written some code in my VB.NET application to send an HTML e-mail
I have written the following simple test in trying to learn Castle Windsor's Fluent
I have written something that uses the following includes: #include <math.h> #include <time.h> #include
I have written a KornShell (ksh) script that sets an array the following way:
I have the following in a program (written in VB.NET): Imports Microsoft.Office.Interop.Excel Public Class
(All of the following is to be written in Java) I have to build
I have written an AIR Application that downloads videos and documents from a server.
I have written a site in Prototype but want to switch to jQuery. Any
I have written a ruby script which opens up dlink admin page in firefox
I have written an AppleScript which when supplied with a Windows network link, will

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.