如何在页面底部设置pdf页脚

如何解决如何在页面底部设置pdf页脚

这是我的 quotationDetail.js 文件,我在 printPdf 函数中创建了 pdf。问题是我想在 footer 处设置 buttom,为此我已将页脚位置设置为绝对 left 0,right 0,buttom 0。但页脚转到页面的中心我的数据在表格行中是动态的,所以我不能给 margin 顶部。我该怎么做?

这是我的截图,页脚在页面中间

import React,{ Component } from "react";
import { connect } from "react-redux";
import { Button } from "react-bootstrap";
import rootAction from "../../redux/actions/index";
import { moment } from "moment";
import * as html2canvas from "html2canvas";
import jsPDF from "jspdf";
import { Font } from "@react-pdf/renderer";
import { FaPrint } from "@react-icons/all-files/fa/FaPrint";
class QuotationDetail extends Component {
  constructor(props) {
    super(props);
    console.log(props);
    this.state = {
      authUser: this.props.authUserProp,//    customers: this.props.history.location.state.customers,//     products: this.props.history.location.state.products,//     phones: this.props.history.location.state.products,//     discount: this.props.history.location.state.discount,//     value: this.props.history.location.state.value,customer_detail: [],contact_name: "",company_name: "",address: "",city: "",country_id: "",contact_email: "",contact_number: "",company_number: "",company_email: "",//  date: this.props.history.location.state.minDate,salutation: "",data: [],quotationData: "",products: [],customerData: "",displayButton: true,headers: true,quotDate: "",//products=this.props.products
    };
  }
 
  printPdf = () => {
    setTimeout(() => {
      console.log("i print function");
      const input = document.getElementById("divToPrint");
      html2canvas(input).then((canvas) => {
        //  console.log("i print function");
        var imgWidth = 210;
        var pageHeight = 290;
        var imgHeight = (canvas.height * imgWidth) / canvas.width;
        var heightLeft = imgHeight;
        const imgData = canvas.toDataURL("image/png");
        const pdf = new jsPDF("p","mm","a4");
        var position = 0;
        var heightLeft = imgHeight;
        pdf.addImage(imgData,"JPEG",position,imgWidth,imgHeight);
        pdf.save("download.pdf");
      });
    },1000);
  };
  getQuotationData = () => {
    axios
      .get("/api/quotation/details",{
        params: {
          api_token: this.state.authUser.api_token,// id: this.state.coustomerid
        },})
      .then((response) => {
        //     console.log(response.data);
        this.setState({
          quotationData: response.data.message,customerData: response.data.customer,quotDate:response.data.quotDate,});
     //   date = moment(response.data.message.created_at).format('DD MMM,YYYY')
      });
  };
    componentDidMount() {
        // console.log(this.state.customers.value)
        // const windowUrl = this.props.location.pathname;
        // const pathnamteString = windowUrl.split('/');
        // this.state.customers= pathnamteString[pathnamteString.length - 1];
        console.log(this.props);
        axios
            .get("/api/v1/customers/detail",{
                params: {
                  //  id: this.state.customers.value
                }
            })
            .then(response => {
                // this.state.data=this.state.phones.map((item,i)=>{
                //     (item.base_price*item.quantity)-(item.quantity*item.base_price)*(item.discount/100)
                // })
                this.setState({
                    customer_detail: response.data.message,contact_name: response.data.message[0].contact_name,company_name: response.data.message[0].company_name,address: response.data.message[0].address,city: response.data.message[0].city_id,country_id: response.data.message[0].country_id,postal_code: response.data.message[0].postal_code,contact_email: response.data.message[0].contact_email,contact_number: response.data.message[0].contact_number,company_number: response.data.message[0].company_number,company_email: response.data.message[0].company_email,salutation: response.data.message[0].salutation,});
              });
    this.getQuotationData();
  }

  render() {
    var count = 0;
    for (var i = 0; i < this.state.data.length; i++) {
      count = count + this.state.data[i];
    }
    const pdfHeader = {
      padding: "10px",borderBottom: "1px solid",borderColor: "#8e8f99",};
    const quotInfo = {
      padding: "10px",width: "100%",};
    const InfoText = {
      fontSize: "18px",margin: "0px",};
    const tableColumn = {
      float: "right",};
    const footer = {
      marginTop: "30%",padding: "10px",paddingBottom: "15px",borderTop: "1px solid",position: "absolute",left: "0px",bottom: "0px",right: "0px",};
    const printIcon = {
        float:"right",fontSize:"30",color:"#333",cursor: "pointer",}
    return (
      <div
        className="container"
        style={{ width: "100%",backgroundColor: "#fff" }}
      >
        <div className="row" style={quotInfo}>
          <div className="col-sm-8"></div>
          <div className="col-sm-4">
            {this.state.displayButton ? (
              <FaPrint
                // color={"coral"}
                // size={30}
                onClick={this.printPdf}
                // style={{ float: "right" }}
                style={printIcon}
              />
            ) : null}
          </div>
        </div>
        <div id="divToPrint">
          <div className="row" style={pdfHeader} id="headers">
            <div className="col-sm-12">
              <div>
                <h1>pdf header image</h1>
              </div>
            </div>
          </div>

          <div className="row" style={quotInfo}>
            <div className="col-sm-9">
              <div>
                {" "}
                <p style={InfoText}>{this.state.customerData.company_name}</p>
              </div>
              <div>
                {" "}
                <p style={InfoText}>
                  {this.state.customerData.address}
                  {this.state.customerData.city_id}
                  {this.state.customerData.country_id}{" "}
                </p>
              </div>
              <div>
                {" "}
                <p style={InfoText}>{this.state.customerData.company_fax}</p>
              </div>
              <div>
                {" "}
                <p style={InfoText}>{this.state.customerData.company_email}</p>
              </div>
              <div>
                {" "}
                <p style={InfoText}>{this.state.customerData.company_number}</p>
              </div>
            </div>
            <div className="col-sm-3">
              <div>
                {" "}
                <p
                  style={{
                    ...InfoText,...{ fontWeight: "bold" },}}
                >
                  <span>Quote Date</span> <span>تاريخ الاقتباس</span>
                </p>
              </div>
              <div>
                {" "}
                <p style={InfoText}>{this.state.quotDate}</p>
              </div>
              <div>
                {" "}
                <p
                  style={{
                    ...InfoText,}}
                >
                  <span>Quote Number</span> <span>رقم الإقتباس</span>
                </p>
              </div>
              <div>
                {" "}
                <p style={InfoText}>{this.state.quotationData.quot_no}</p>
              </div>
              <div>
                {" "}
                <p
                  style={{
                    ...InfoText,}}
                >
                  <span>Reference</span> <span>مرجع</span>
                </p>
              </div>
              <div>
                {" "}
                <p style={InfoText}>{this.state.quotationData.po_reference}</p>
              </div>
            </div>
          </div>
          <div className="row" style={quotInfo}>
            <div className="col-md-12 col-lg-12 col-sm-12">
              <table class="table table-responsive table-bordered w-100">
                <thead>
                  <tr>
                    <th
                      scope="col"
                      style={{
                        backgroundColor: "#b6c0c6",}}
                    >
                      SNO.
                    </th>

                    <th
                      scope="col"
                      style={{
                        textAlign: "center",backgroundColor: "#b6c0c6",}}
                    >
                      Product/Service<br></br> المنتج / الخدمة
                    </th>
                    <th
                      scope="col"
                      style={{
                        textAlign: "center",}}
                    >
                      Quantity <br></br> كمية
                    </th>
                    <th
                      scope="col"
                      style={{
                        textAlign: "center",}}
                    >
                      Unit Price<br></br> قائمة الأسعار
                    </th>
                    <th
                      scope="col"
                      style={{
                        textAlign: "center",}}
                    >
                      Sale Price<br></br> سعر البيع
                    </th>
                    <th
                      scope="col"
                      style={{
                        textAlign: "center",}}
                    >
                      Discount<br></br> خصم
                    </th>

                    <th
                      scope="col"
                      style={{
                        textAlign: "center",}}
                    >
                      VAT<br></br> ضريبة القيمة المضافة
                    </th>
                    <th
                      scope="col"
                      style={{
                        textAlign: "center",}}
                    >
                      Total<br></br> مجموع
                    </th>
                  </tr>
                </thead>
                {this.state.quotationData.lineproducts ? (
                  <tbody>
                    {this.state.quotationData.lineproducts.map(
                      (product,idx) => {
                        var tempprice =
                          (product.sale_price - product.discount) *
                          product.quantity;
                        var tempTotal =
                          tempprice + parseInt(product.product_vat);
                        return (
                          <>
                            <tr>
                              <th scope="row">{product.id}</th>

                              <td>
                                {product.product_name}
                              </td>
                              <td>{product.quantity}</td>
                              <td>{product.unit_price}</td>
                              <td>{product.sale_price}</td>
                              <td>{product.discount}</td>
                              <td>{product.product_vat}</td>
                              <td>{tempTotal}</td>
                            </tr>
                          </>
                        );
                      }
                    )}
                    ;
                  </tbody>
                ) : null}
              </table>
            </div>
            <div className="col-sm-12">
              <table
                class="table table-responsive  table-bordered"
                id="quottable"
              >
                <tbody className={"tableBody"}>
                  <tr id="tableRow">
                    <td className={"tableColumn"}>
                      {this.state.quotationData.total_amount} SAR
                    </td>
                    <td className={"tableColumn"}>Total</td>
                  </tr>
                </tbody>
              </table>
            </div>
            <div className="col-sm-12">
              <table
                class="table table-responsive  table-bordered"
                id="quottable"
              >
                <tbody className={"tableBody"}>
                  <tr id="tableRow">
                    <td className={"tableColumn"}>
                      {this.state.quotationData.total_discount} SAR
                    </td>
                    <td className={"tableColumn"}>Discount</td>
                  </tr>
                </tbody>
              </table>
            </div>
            <div className="col-sm-12">
              <table
                class="table table-responsive  table-bordered"
                id="quottable"
              >
                <tbody className={"tableBody"}>
                  <tr id="tableRow">
                    <td className={"tableColumn"}>
                      {this.state.quotationData.total_amount -
                        this.state.quotationData.total_discount}{" "}
                      SAR
                    </td>
                    <td className={"tableColumn"}>Subtotal</td>
                  </tr>
                </tbody>
              </table>
            </div>
            <div className="col-sm-12">
              <table
                class="table table-responsive  table-bordered"
                id="quottable"
              >
                <tbody className={"tableBody"}>
                  <tr id="tableRow">
                    <td className={"tableColumn"}>
                      {this.state.quotationData.total_vat} SAR
                    </td>
                    <td className={"tableColumn"}>Vat</td>
                  </tr>
                </tbody>
              </table>
            </div>
            <div className="col-sm-12">
              <table
                class="table table-responsive  table-bordered"
                id="quottable"
              >
                <tbody className={"tableBody"}>
                  <tr id="tableRow">
                    <td className={"tableColumn"}>
                      {this.state.quotationData.grand_total} SAR
                    </td>
                    <td className={"tableColumn"}>Grand Total</td>
                  </tr>
                </tbody>
              </table>
            </div>
          </div>
          
          <div className="row" style={quotInfo}>
            <div className="col-sm-12">
              <div>
                {" "}
                <p
                  style={{
                    ...InfoText,...{ marginBottom: "10px" },}}
                >
                  Hope you find our quotation reasonable and we look forward to
                  receive your valued purchase order soon.
                </p>
              </div>
            </div>
            <div className="col-sm-12">
              <div>
                {" "}
                <p style={InfoText}>Refer to Company Terms and Conditions.</p>
              </div>
            </div>
            <div className="col-sm-12">
              <div>
                <p
                  style={{
                    ...InfoText,...{
                      marginTop: "10px",fontWeight: "bold",},}}
                >
                  Notes:20-09-032145 PCOC
                </p>
              </div>
            </div>
          </div>
          <div className="row" style={quotInfo}>
            <div className="col-sm-6">
              <div>
                <p
                  style={{
                    ...InfoText,}}
                >
                  Bank Details
                </p>
              </div>
              <div>
                {" "}
                <p style={InfoText}>Saudi Fransi Bank</p>
              </div>
              <div>
                {" "}
                <p style={InfoText}>IBAN: 789577854225222</p>
              </div>
              <div>
                {" "}
                <p style={InfoText}>ACCOUNT NO: 562346535</p>
              </div>
              <div>
                {" "}
                <p style={InfoText}>SWIFT:BSFRSARI</p>
              </div>
            </div>
          </div>

          <div className="row" style={quotInfo}>
            <div className="col-sm-9">
              <div>
                {" "}
                <p style={InfoText}>For Customer Approval Only</p>
              </div>
              <div>
                {" "}
                <p style={InfoText}>Name: </p>
              </div>
              <div>
                {" "}
                <p style={InfoText}>Position:</p>
              </div>
              <div>
                {" "}
                <p style={InfoText}>Employee #:</p>
              </div>
              <div>
                {" "}
                <p style={InfoText}>Signature</p>
              </div>
              <div>
                {" "}
                <p style={InfoText}>Company Stamp</p>
              </div>
            </div>
            <div className="col-sm-3">
              <div>
                {" "}
                <p style={InfoText}>Prepared By</p>
              </div>
              <div>
                {" "}
                <p style={InfoText}>--------------------------- </p>
              </div>
              <div>
                {" "}
                <p style={InfoText}>Hafi Ali</p>
              </div>
              <div>
                {" "}
                <p style={InfoText}>Department:</p>
              </div>
              <div>
                {" "}
                <p style={InfoText}>Mobile: +14785962452</p>
              </div>
              <div>
                {" "}
                <p style={InfoText}>Email:hali@qqcms.com</p>
              </div>
            </div>
          </div>
          <div className="row" style={footer}>
            <div className="col-sm-9">
              <div>
                {" "}
                <p
                  style={{
                    ...InfoText,...{ fontSize: "16px" },}}
                >
                  Selma Center 1st Floor,ImamAbdullah Bin Saud Road,Ash
                  Shuhada,Riyadh
                </p>
              </div>
              <div>
                {" "}
                <p
                  style={{
                    ...InfoText,...{
                      fontSize: "16px",marginTop: "-3px",}}
                >
                  P.O. Box 88458 Riyadh 11662{" "}
                </p>
              </div>
              <div>
                {" "}
                <p
                  style={{
                    ...InfoText,}}
                >
                  Ph. : +966 784521659
                </p>
              </div>
              <div>
                {" "}
                <p
                  style={{
                    ...InfoText,}}
                >
                  Fax : +966 784521659
                </p>
              </div>
              <div>
                {" "}
                <p
                  style={{
                    ...InfoText,}}
                >
                  https://www.qqcms.com.sa/
                </p>
              </div>
            </div>
            <div className="col-sm-3">
              <div>
                {" "}
                <p
                  style={{
                    ...InfoText,marginTop: "15%",}}
                >
                  <span>15/01/2021</span>
                </p>
              </div>
            </div>
          </div>
        </div>
      </div>
    );
  }
}
const mapStateToProps = (state) => {
  return {
    authUserProp: state.authUserReducer,activeComponentProp: state.activeComponentReducer,};
};

const mapDispatchToProps = (dispatch) => {
  return {
    setAuthUserProp: (user) => dispatch(setAuthUser(user)),setActiveComponentProp: (component) =>
      dispatch(rootAction.setActiveComponent(component)),};
};
export default connect(mapStateToProps,mapDispatchToProps)(QuotationDetail);

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-