I have a fastapi server that returns an html page, but whenever I make a call to the server using pdfkit.from_url function it return a warped pdf, and when i go to my server via browser, it returns the html looking normal, even when i hit ctrl+p to print to pdf!, I don’t know what the issue might be but here is the code
def click(e):
print(box_group.value, inspectors_list)
print(f"you click{job.value}")
#hacer una función para que se guarde el reporte en la base de datos y se haga un numero de reporte
url = f"{api_url}?test={box_group.value}&report_num={box_group.value}-R-{year}-234&client_name={client_name.value}&plant={plant_location.value}&contact_name={contact.value}&part_desc={Description.value}&material={material.value}&heat={heat.value}&j_order={job_order.value}&j_qty={job.value}&od={od_val.value}&id={id_val.value}&width={thick_val.value}&height={height_val.value}&NDE={nde_val.value}&crit_accept={accept_val.value}&rough={surface_val.value}&uti_sn={uti_sn.value}&sn1={test_sn.value}&d_cal={distance.value}&sens_block={sensitivity.value}¬ch={notch.value}&rec_lvl={record.value}&ax_scanning={axial_x.value}&circ_ax_scanning={circumferental_x.value}&method={inspection.value}&coupling={coupling.value}&stage={inspector_s.value}&remarks={textarea.value}&insp_name={inspectors_list[0]}&ndt_act={ndt_act.value}"
print(url)
if check.value:
url = url + f"&acc_sn={sn.value}"
else:
url = url + f"&rej_sn={sn.value}"
pdfurldownload = str(downloads_path) + "\" + str(box_group.value) + "-R-" + str(year) + ".pdf"
print(pdfurldownload)
pdfkit.from_url(url, pdfurldownload, configuration=config)
here are some images attached so that you can see how the pdf looks like, one without image, and another with the logo image
The one with the logo
The one without the logo
This is how its supposed to look when calling to the server
I think the issue might be because I have my css inside the html but I dont see why that would be a problem
heres the html code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<style>
.container {
display: flex;
justify-content: space-around;
border: 1px solid black;
}
div.container > div.title_section {
width: 33.33%;
}
.table {
flex-direction: column;
}
.row {
display: inline-flex;
flex-direction: row;
justify-content: space-evenly;
border: 1px solid black;
flex-basis: content;
}
.data_table {
display: flex;
flex-direction: column;
}
.data_row:last-child{
border-bottom: none;
/* border: 5px solid slateblue; */
}
.data_row {
display: inline-flex;
flex-direction: row;
justify-content: space-between;
/* border-top: 1px solid black; */
border-bottom: 1px solid black;
flex-wrap: wrap;
/* align-content: center; */
align-items: center;
vertical-align: middle;
/* align-items: stretch; */
}
div.data_row > span {
align-self: stretch;
/* height: 60px; */
/* padding-top: 20px;
padding-bottom: 20px; */
}
.data_cell{
box-sizing: border-box;
border-left: 1px solid black;
border-right: 1px solid black;
align-self: stretch;
}
.data_cell:last-child {
border-right: none;
}
.bold_column_name {
font-weight: 700;
font-size: 12px;
border-right: 1px solid black;
/* border-left: 1px solid black; */
background-color: #c4c3c7;
align-items: center;
justify-content: center;
padding-left: 4.37px;
padding-right: 4.37px;
}
.column_name_row {
justify-content: space-evenly;
align-content: stretch;
}
.bold_column_name:last-child {
border-right: none;
}
.two_items {
width: 50%;
border: none;
}
.three_items {
width: 33.33%;
}
.four_items {
width: 25%;
}
.five_items {
width: 20%;
border-left: none;
border-right: 1px solid black;
}
.six_items {
width: 16.66%;
}
._13_items {
width: 7.6925%;
font-size: 9px;
}
.image {
flex-shrink: 1;
width: 100%;
height: 100%;
}
.table_title {
height: 30px;
display: flex;
align-items: center;
font-weight: 700;
font-size: 18px;
background: #d1d1d1;
border-top: none;
border-bottom: none;
}
.table_subtitle {
font-size: 15px;
font-weight: 600;
background: #607fee;
border: none;
}
.bold_cell {
font-weight: 700;
font-size: 15px;
border-right: 0px solid black;
border-left: 0px solid black;
}
.title {
color: #3d0cc4;
font-weight: 700;
font-size: 20px;
}
.title_section{
display: flex;
align-items: center;
}
div.row > span {
border-left: 1px solid black;
border-right: 1px solid black;
width: 97.9px;
font-size: 10px;
padding-top: 14.2445px;
padding-bottom: 15.2445px;
}
.separator {
height: 20px;
}
.bold_cell.two_items {
border-right: 1px solid black;
}
.setup_table {
height: 35px;
}
/* Set A4 size */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
text-align: center;
}
@page {
size: A4;
margin: 0;
}
/* Set content to fill the entire A4 page */
html,
body {
width: 210mm;
height: 297mm;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
}
/* Style content with shaded background */
.content {
width: 80%;
/* Adjust the width as needed */
height: 80%;
/* Adjust the height as needed*/
padding: 20px;
box-sizing: border-box;
font-family: Arial, sans-serif;
/* background-color: #f0f0f0; */
/* Light gray shade */
}
</style>
<body>
<div class="content">
<div class="container">
<div class="title_section">
<!-- <img class="image" src="..staticimagesndtklogo.png" alt="ndtklogo"> -->
</div>
<div class="title_section">
<span class="title">
{{test}} Inspection Summary
</span>
</div>
<div class="container table title_section">
<div class="row">
<span>Report Number: </span><span>{{report_num}}</span>
</div>
<div class="row">
<span>Date: </span><span>{{date}}</span>
</div>
</div>
</div>
<div class="separator"></div>
<div class="container table_title" style="border-top: 1px solid black;">
<span>Datos del cliente/Customer Information</span>
</div>
<div class="container data_table">
<div class="data_row">
<div class="data_cell bold_cell two_items">
<span class="">Nombre del Cliente/Customer Name</span>
</div>
<div class="data_cell two_items">
<span class="">{{client_name}}</span>
</div>
</div>
<div class="data_row">
<div class="data_cell bold_cell four_items">
<span class="">Planta/Plant</span>
</div>
<div class="data_cell four_items">
<span class="">{{plant}}</span>
</div>
<div class="data_cell bold_cell four_items">
<span class="">Persona De Contacto/Contact Name</span>
</div>
<div class="data_cell four_items">
<span class="">{{contact_name}}</span>
</div>
</div>
</div>
<div class="container table_title">
<span>Datos de la Pieza/Part Information</span>
</div>
<div class="container data_table">
<div class="data_row">
<div class="data_cell bold_cell two_items">
<span>Descripción de la Pieza/Part Description</span>
</div>
<div class="data_cell two_items">
{{part_desc}}
</div>
</div>
<div class="data_row">
<div class="data_cell bold_cell four_items">
<span>Tipo de material/Material Spec</span>
</div>
<div class="data_cell four_items">
<span>{{material}}</span>
</div>
<div class="data_cell bold_cell four_items">
<span>Colada/Heat</span>
</div>
<div class="data_cell four_items">
<span>{{heat}}</span>
</div>
</div>
<div class="data_row">
<div class="data_cell bold_cell four_items">
<span>Orden de trabajo cliente/Job Order</span>
</div>
<div class="data_cell four_items">
<span>{{j_order}}</span>
</div>
<div class="data_cell bold_cell four_items">
<span>Cantidad/Job QTY</span>
</div>
<div class="data_cell four_items">
<span>{{j_qty}}</span>
</div>
</div>
</div>
<div class="container table_title">
<span>Dimensiones/Dimensions</span>
</div>
<div class="container data_table">
<div class="data_row">
<div class="data_cell bold_cell four_items">
<span>OD</span>
</div>
<div class="data_cell four_items">
<span>{{od}}</span>
</div>
<div class="data_cell bold_cell four_items">
<span>ID</span>
</div>
<div class="data_cell four_items">
<span>{{id}}</span>
</div>
</div>
<div class="data_row">
<div class="data_cell bold_cell four_items">
<span>Thickness</span>
</div>
<div class="data_cell four_items">
<span>{{width}}</span>
</div>
<div class="data_cell bold_cell four_items">
<span>Height</span>
</div>
<div class="data_cell four_items">
<span>{{height}}</span>
</div>
</div>
<div class="data_row">
<div class="data_cell bold_cell four_items">
<span>Especificaciones PND/ NDE Specifications</span>
</div>
<div class="data_cell four_items">
<span>{{NDE}}</span>
</div>
<div class="data_cell bold_cell four_items">
<span>Criterio de Aceptación/ Acceptance Criteria</span>
</div>
<div class="data_cell four_items">
<span>{{crit_accept}}</span>
</div>
</div>
<div class="data_row">
<div class="data_cell bold_cell two_items">
<span>Acabado Superficial/ Surface Roughtness</span>
</div>
<div class="data_cell two_items">
<span>{{rough}}</span>
</div>
</div>
</div>
<div class="container table_title">
<span>Equipo de ultrasonido/UT Instrument</span>
</div>
<div class="container data_table">
<div class="data_row">
<div class="data_cell bold_cell six_items">
<span>Marca/ Brand</span>
</div>
<div class="data_cell six_items">
<span>{{uti_brand}}</span>
</div>
<div class="data_cell bold_cell six_items" style="border-right: 1px solid black;">
<span>Modelo/ Model</span>
</div>
<div class="data_cell six_items" style="border-left: none;">
<span>{{uti_model}}</span>
</div>
<div class="data_cell bold_cell six_items">
<span>N° de Serie/ Serial N°</span>
</div>
<div class="data_cell six_items">
<span>{{uti_sn}}</span>
</div>
</div>
<div class="data_row">
<div class="data_cell bold_cell four_items">
<span>Fecha de Calibración/ Calibration Date</span>
</div>
<div class="data_cell four_items">
<span>{{cal_date}}</span>
</div>
<div class="data_cell bold_cell four_items">
<span>Prox. Calibración/ Calibration Due Date</span>
</div>
<div class="data_cell four_items">
<span>{{cal_due}}</span>
</div>
</div>
</div>
<div class="container table_title" style="border-top: 1px solid black;">
<span>Calibración del instrumento/ Test Calibration Setup</span>
</div>
<div class="container data_table">
<div class="data_row">
<div class="data_cell bold_cell table_subtitle two_items">
<span>Trasductor/Probe Data</span>
</div>
<div class="data_cell bold_cell table_subtitle two_items" style="border-right: none;">
<span>Calibración de Sensibilidad/Sensitivity Calibration</span>
</div>
</div>
</div>
<div class="container data_table">
<div class="data_row column_name_row">
<div class="data_cell bold_column_name _13_items">
<span>marca brand</span>
</div>
<div class="data_cell bold_column_name _13_items">
<span>modelo model</span>
</div>
<div class="data_cell bold_column_name _13_items">
<span>N° de Serie Serial N°</span>
</div>
<div class="data_cell bold_column_name _13_items">
<span>Frec. Freq.</span>
</div>
<div class="data_cell bold_column_name _13_items">
<span>Tamaño Size</span>
</div>
<div class="data_cell bold_column_name _13_items">
<span>Angulo Refracted Angle</span>
</div>
<div class="data_cell bold_column_name _13_items">
<span>Sensibilidad Sensitivity Method</span>
</div>
<div class="data_cell bold_column_name _13_items">
<span>Referencia Reference Size</span>
</div>
<div class="data_cell bold_column_name _13_items">
<span>Nivel de referencia Ref. Level</span>
</div>
<div class="data_cell bold_column_name _13_items">
<span>Transfer. Transfer Correction</span>
</div>
<div class="data_cell bold_column_name _13_items">
<span>Escaneo Scanning Level</span>
</div>
<div class="data_cell bold_column_name _13_items">
<span>Rango Screen Range</span>
</div>
<div class="data_cell bold_column_name _13_items">
<span>Tipo Escaneo Scan Type</span>
</div>
</div>
<div class="data_row setup_table">
...
</div>
<div class="data_row setup_table">
...
</div>
<div class="data_row setup_table">
...
</div>
<div class="data_row setup_table">
...
</div>
<div class="data_row setup_table">
...
</div>
</div>
<div class="separator"></div>
...
<div class="separator"></div>
<div class="container table_title" style="border-top: 1px solid black;">
<span>Bloques de calibración / Calibration Blocks</span>
</div>
<div class="container data_table">
<div class="data_row">
<div class="data_cell bold_cell four_items" style="font-size: 12px;">
<span>Calibración de Distancia/Distance Calibration Verificacion del Haz Angular/Angle Verification</span>
</div>
<div class="data_cell four_items" style="font-size: 10px;">
<span>{{d_cal}}</span>
</div>
<div class="data_cell bold_cell four_items" style="font-size: 12px;">
<span>Bloque de Sensibilidad Sensitivity Block</span>
</div>
<div class="data_cell four_items" style="font-size: 10px;">
<span>{{sens_block}}</span>
</div>
</div>
<div class="data_row">
<div class="data_cell bold_cell two_items" style="font-size: 12px;">
<span>PROF. DE LA MUESCA / NOTCH DEPTH</span>
</div>
<div class="data_cell two_items" style="font-size: 12px;">
<span>{{notch}}</span>
</div>
</div>
<div class="data_row">
<div class="data_cell bold_cell two_items" style="font-size: 12px;">
<span>NIVEL DE REGISTRO / RECORDING LEVEL</span>
</div>
<div class="data_cell two_items" style="font-size: 12px;">
<span>{{rec_lvl}}</span>
</div>
</div>
<div class="container table_title">
<span>DIRECCION DE ESCANEO / SCANNIG DIRECTION </span>
</div>
</div>
<div class="container data_table">
<div class="data_row">
<div class="data_cell bold_cell four_items">
<span>Axial Scanning</span>
</div>
<div class="data_cell four_items" style="font-size: 13px;">
<span style="font-weight: 700;">Face - </span><span>{{ax_scanning}}</span>
</div>
<div class="data_cell bold_cell four_items">
<span>Circunferencia/ Axial Scanning</span>
</div>
<div class="data_cell four_items" style="font-size: 12px;">
<span style="font-weight: 700;">OD - </span><span>{{circ_ax_scanning}}</span>
</div>
</div>
</div>
<div class="container table_title">
<span>INFORMACION DE LA INSPECCION / INSPECTION INFORMATION</span>
</div>
<div class="container data_table">
<div class="data_row">
<div class="data_cell bold_cell four_items"><span>METODO DE INSPECCION / INSPECTION METHOD</span></div>
<div class="data_cell four_items"><span>{{method}}</span></div>
<div class="data_cell bold_cell four_items"><span>ACOPLANTE / COUPLING AGENT</span></div>
<div class="data_cell four_items"><span>{{coupling}}</span></div>
</div>
<div class="data_row">
<div class="data_cell bold_cell two_items"><span>ETAPA DE INSPECCIÓN / INSPECTION STAGE</span></div>
<div class="data_cell two_items"><span>{{stage}}</span></div>
</div>
</div>
<div class="container table_title">
<span>RESULTADOS DE LA INSPECCION / INSPECTION RESULTS</span>
</div>
<div class="container data_table">
<div class="data_row">
<div class="data_cell bold_cell" style="width: 33.33%;"><span>RESULTADO DE LA INSPECCION / INSPECTION RESULTS</span></div>
<div class="data_cell" style="width: 66.66%; border-left: none;">
<div class="container data_table" style="border: none;">
<div class="data_row" style="border-left: none;">
<div class="data_cell three_items"><span>Aceptado/ Accepted</span></div>
<div class="data_cell bold_cell three_items"><span>N° de Serie/ SN</span></div>
<div class="data_cell three_items"><span>{{acc_sn}}</span></div>
</div>
<div class="data_row" style="border-left: none;">
<div class="data_cell three_items"><span>Rechazado/ Rejected</span></div>
<div class="data_cell bold_cell three_items"><span>N° de Serie/ SN</span></div>
<div class="data_cell three_items"><span>{{rej_sn}}</span></div>
</div>
</div>
</div>
</div>
<div class="data_row">
<div class="data_cell bold_cell" style="width: 33.33%;">
<span>Observaciones / Remarks</span>
</div>
<div class="data_cell" style="width: 66.66%; display: flex; justify-content: flex-start;">
<span>{{remarks}}</span>
</div>
</div>
</div>
<div class="container table_title">
<span>Certificación del personal / Personnel Certification</span>
</div>
<div class="container data_table">
<div class="data_row">
<div class="data_cell bold_cell five_items" style="border-right: 1px solid black; font-size: 10px;">
<span>NOMBRE DEL INSPECTOR INSPECTOR NAME</span>
</div>
<div class="data_cell bold_cell five_items" style="border-right: 1px solid black; font-size: 10px;">
<span>NIVEL DE CERTIFICACION CERTIFICATION LEVEL</span>
</div>
<div class="data_cell bold_cell five_items" style="border-right: 1px solid black; font-size: 10px;">
<span>ACTIVIDAD NDT ACTIVITY</span>
</div>
<div class="data_cell bold_cell five_items" style="border-right: 1px solid black; font-size: 10px;">
<span>FECHA DE VENCIMIENTO CERTIFICATION DUE DATE</span>
</div>
<div class="data_cell bold_cell five_items" style="font-size: 10px;">
<span>FIRMA DEL INSPECTOR INSPECTOR SIGNATURE</span>
</div>
</div>
<div class="data_row">
<div class="data_cell five_items">
<span>{{insp_name}}</span>
</div>
<div class="data_cell five_items">
<span>{{cert_lvl}}</span>
</div>
<div class="data_cell five_items">
<span>{{ndt_act}}</span>
</div>
<div class="data_cell five_items">
<span>{{cert_due}}</span>
</div>
<div class="data_cell five_items">
<span><img src="" alt="Firma"></span>
</div>
</div>
</div>
</div>
</body>
</html>
user24594552 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.