list fdf resultater
Jeg vil gerne lave en upload funkrion det læser filen igennem for alle verdier som:%FDF-1.2
%
1 0 obj
<</FDF<</Annots[2 0 R 3 0 R 4 0 R 5 0 R 6 0 R 7 0 R 8 0 R 9 0 R 10 0 R 11 0 R 12 0 R 13 0 R 14 0 R 15 0 R 16 0 R 17 0 R 18 0 R 19 0 R 20 0 R 21 0 R 22 0 R 23 0 R 24 0 R 25 0 R 26 0 R 27 0 R 28 0 R 29 0 R 30 0 R 31 0 R 32 0 R 33 0 R 34 0 R 35 0 R 36 0 R 37 0 R 38 0 R 39 0 R 40 0 R 41 0 R 42 0 R 43 0 R 44 0 R 45 0 R 46 0 R 47 0 R 48 0 R 49 0 R 50 0 R 51 0 R 52 0 R 53 0 R 54 0 R 55 0 R 56 0 R 57 0 R 58 0 R 59 0 R 60 0 R 61 0 R 62 0 R 63 0 R 64 0 R 65 0 R 66 0 R 67 0 R 68 0 R 69 0 R 70 0 R 71 0 R 72 0 R 73 0 R 74 0 R 75 0 R 76 0 R 77 0 R 78 0 R 79 0 R 80 0 R 81 0 R 82 0 R 83 0 R 84 0 R 85 0 R 86 0 R 87 0 R 88 0 R 89 0 R 90 0 R 91 0 R 92 0 R 93 0 R 94 0 R 95 0 R]/F(/C/Users/henand05/Documents/SDU/Gravering/Tegninger/45.1/K07.1_L45.1F_H1.01_EN00_N112.pdf)/ID[<68B5F84E0D501A4EB84CF40727B1899A><47FC3F6F53047240A665C0638D1D3C19>]/UF(/C/Users/henand05/Documents/SDU/Gravering/Tegninger/45.1/K07.1_L45.1F_H1.01_EN00_N112.pdf)>>/Type/Catalog>>
endobj
2 0 obj
<</C[1.0 0.819611 0.0]/Contents(Print:Tavle:ET.45.1A.0W.02\r23-23-15 EDB-15 EDB-PDS\r<824>-[236])/CreationDate(D:20230323081009+01'00')/F 28/M(D:20230323115101+01'00')/NM(e5ab9eab-9c0a-4abe-9fa3-bfec97960cd3)/Name/Circle/Page 0/Popup 3 0 R/RC(<?xml version="1.0"?><body xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:APIVersion="Acrobat:22.3.0" xfa:spec="2.0.2" ><p dir="ltr"><span dir="ltr" style="font-size:10.1pt;text-align:left;font-weight:normal;f\
ont-style:normal">ET.45.1A.0W.02<824></span></p></body>)/Rect[549.719 1258.6 569.719 1278.6]/Subj(Gul seddel)/Subtype/Text/T(hjia)/Type/Annot>>
endobj
3 0 obj
<</F 28/Open false/Page 0/Parent 2 0 R/Rect[2976.0 1164.6 3180.0 1278.6]/Subtype/Popup/Type/Annot>>
endobj
4 0 obj
<</C[1.0 0.819611 0.0]/Contents(Print:ET.45.1A.0W.02<824>\rPrint:ET.45.1A.00.04[264])/CreationDate(D:20230323081014+01'00')/F 28/M(D:20230323115053+01'00')/NM(0cf1b242-7fb7-4299-be39-6cb10979ccf8)/Name/Circle/Page 0/Popup 5 0 R/RC(<?xml version="1.0"?><body xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:APIVersion="Acrobat:22.3.0" xfa:spec="2.0.2" ><p dir="ltr"><span dir="ltr" style="font-size:10.1pt;text-align:left;font-weight:normal;f\
ont-style:normal">ET.45.1A.0W.02<824> ET.45.1A.00.04[264]</span></p></body>)/Rect[475.002 1277.79 495.002 1297.79]/Subj(Gul seddel)/Subtype/Text/T(hjia)/Type/Annot>>
endobj
5 0 obj
<</F 28/Open false/Page 0/Parent 4 0 R/Rect[2976.0 1192.19 3180.0 1306.19]/Subtype/Popup/Type/Annot>>
endobj
6 0 obj
<</C[1.0 0.819611 0.0]/Contents(Print:ET.45.1A.0W.02<822>\rPrint:ET.45.1A.00.04[264])/CreationDate(D:20230323081041+01'00')/F 28/M(D:20230323115032+01'00')/NM(16b4346c-09a5-4929-bd59-d06a9c4c5c1c)/Name/Circle/Page 0/Popup 7 0 R/RC(<?xml version="1.0"?><body xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:APIVersion="Acrobat:22.3.0" xfa:spec="2.0.2" ><p dir="ltr"><span dir="ltr" style="font-size:10.3pt;text-align:left;font-weight:normal;f\
ont-style:normal">ET.45.1A.0W.02<822> ET.45.1A.00.04[264]</span></p></body>)/Rect[483.499 1382.37 503.499 1402.37]/Subj(Gul seddel)/Subtype/Text/T(hjia)/Type/Annot>>
endobj
7 0 obj
<</F 28/Open false/Page 0/Parent 6 0 R/Rect[2976.0 1288.37 3180.0 1402.37]/Subtype/Popup/Type/Annot>>
endobj
8 0 obj
<</C[1.0 0.819611 0.0]/Contents(263)/CreationDate(D:20230323125609+01'00')/F 28/M(D:20230323125617+01'00')/NM(048486ab-8cd2-48a3-a83c-64eb9ea7785c)/Name/Circle/Page 0/Popup 9 0 R/RC(<?xml version="1.0"?><body xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:APIVersion="Acrobat:22.3.0" xfa:spec="2.0.2" ><p dir="ltr"><span dir="ltr" style="font-size:10.3pt;text-align:left;font-weight:normal;f\
ont-style:normal">263</span></p></body>)/Rect[682.324 1610.65 702.324 1630.65]/Subj(Gul seddel)/Subtype/Text/T(hjia)/Type/Annot>>
endobj
9 0 obj
<</F 28/Open true/Page 0/Parent 8 0 R/Rect[2976.0 1516.65 3180.0 1630.65]/Subtype/Popup/Type/Annot>>
endobj
10 0 obj
<</C[1.0 0.819611 0.0]/Contents(263)/CreationDate(D:20230323125617+01'00')/F 28/M(D:20230323125707+01'00')/NM(4665585c-d5e0-4285-bb47-5e33bb14426e)/Name/Circle/Page 0/Popup 11 0 R/RC(<?xml version="1.0"?><body xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:APIVersion="Acrobat:22.3.0" xfa:spec="2.0.2" ><p dir="ltr"><span dir="ltr" style="font-size:10.3pt;text-align:left;font-weight:normal;f\
ont-style:normal">263</span></p></body>)/Rect[717.36 1609.25 737.36 1629.25]/Subj(Gul seddel)/Subtype/Text/T(hjia)/Type/Annot>>
endobj
hvor der gerne skal udlæses verdier fra:
/Contents()
/CreationDate()
hvad der står efter '/Name/'
/T()
og af det skal den kun gøre hvis '/Contents()' starter med 'Print:'
og så skal den dele verdien op i stumper:
Hvis vedien efter 'Print:' er 'Tavle:'
$output['tavle'] = (alt mellem 'Tavle:' og '\r')
$output['date'] = (verdi af /CreationDate())
$output['type'] = (verdi af /T())
$output['creator'] = (verdi af hvad der står efter '/Name/')
$output['field_1'] = (første del af den næste del før '-')
$output['field_2'] = (næste del af den næste del anden før '-')
$output['field_3'] = (næste del af den næste del tredie før '-')
$output['field_4'] = -||-
$output['field_5'] = -||-
dette skal den liste op i en tabel
men står der ikke 'Tavle:'
skal den lave en anden liste med verdierne
Troede jeg var på rette vej, men får tilbagefald.
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (isset($_FILES["file"])) {
$file_name = $_FILES["file"]["name"];
$file_type = $_FILES["file"]["type"];
$file_size = $_FILES["file"]["size"];
$file_tmp = $_FILES["file"]["tmp_name"];
// Check if the file is an FDF file
if (strtolower(pathinfo($file_name, PATHINFO_EXTENSION)) == "fdf") {
// Read the contents of the file and replace all \r with \n
$file_contents = file_get_contents($file_tmp);
$file_contents = str_replace("\r", "\n", $file_contents);
// Extract the data
preg_match_all('/Contents\((.*?)\)/', $file_contents, $matches);
$output = array(
"list" => array(),
"tavle" => "",
"field_1" => array(),
"field_2" => array(),
"field_3" => array(),
"field_4" => array(),
"field_5" => array()
);
foreach ($matches[1] as $match) {
if (strpos($match, "Print:") === 0) {
// Add value to list
$output["list"][] = trim(substr($match, 6));
} elseif (strpos($match, "Tavle:") === 0) {
// Set table value
$output["tavle"] = trim(substr($match, 6));
} else {
// Set field values
$field_values = explode("-", $match);
$output["field_1"][] = trim($field_values[0]);
$output["field_2"][] = trim($field_values[1]);
$output["field_3"][] = trim($field_values[2]);
$output["field_4"][] = trim($field_values[3]);
$output["field_5"][] = trim($field_values[4]);
}
}
// Display the data in a Bootstrap table
echo "<div class='container'><h2>File Contents</h2>";
echo "<table class='table'>";
if (!empty($output["list"])) {
echo "<tr>
<th>Print List:</th>
<td>";
echo "<ul>";
foreach ($output["list"] as $list_item) {
echo "<li>" . $list_item . "</li>";
}
echo "</ul>";
echo "</td></tr>";
}
if (!empty($output["tavle"])) {
echo "<tr>";
echo "<th>Tavle:</th>";
echo "<td>" . $output["tavle"] . "</td>";
echo "</tr>";
}
if (!empty($output["field_1"])) {
echo "<tr>";
echo "<th>Field 1:</th>";
echo "<td><ul>";
foreach ($output["field_1"] as $field) {
echo "<li>" . $field . "</li>";
}
echo "</ul></td>";
echo "</tr>";
}
if (!empty($output["field_2"])) {
echo "<tr>";
echo "<th>Field 2:</th>";
echo "<td><ul>";
foreach ($output["field_2"] as $field) {
echo "<li>" . $field . "</li>";
}
echo "</ul></td>";
echo "</tr>";
}
if (!empty($output["field_3"])) {
echo "<tr>";
echo "<th>Field 3:</th>";
echo "<td><ul>";
foreach ($output["field_3"] as $field) {
echo "<li>" . $field . "</li>";
}
echo "</ul></td>";
echo "</tr>";
}
if (!empty($output["field_4"])) {
echo "<tr>";
echo "<th>Field 4:</th>";
echo "<td><ul>";
foreach ($output["field_4"] as $field) {
echo "<li>" . $field . "</li>";
}
echo "</ul></td>";
echo "</tr>";
}
if (!empty($output["field_5"])) {
echo "<tr>";
echo "<th>Field 5:</th>";
echo "<td><ul>";
foreach ($output["field_5"] as $field) {
echo "<li>" . $field . "</li>";
}
echo "</ul></td>";
echo "</tr>";
}
echo "</table></div>";
} else {
echo "<div class='container'><div class='alert alert-danger'>Invalid file format. Please upload an FDF file.</div></div>";
}
} else {
echo "<div class='container'><div class='alert alert-danger'>Please select a file to upload.</div></div>";
}
}
?>
</body>
</html>