Merge visible PDF in one file
I have a table named "Allegati". Inside it, there's a field called "File" which contains a PDF. In another table called "DOC FIERA", I have created a reference to "Allegati" in such a way that if a value in the multiple dynamic choice field named "Zertifikate" is selected, then the corresponding PDF appears. I did this with the following code:
let x := for loop in numbers(Zertifikate) do
record(Allegati,loop)
end;
count(x[Descrizione = "Elektro - Zertifikat"]) > 0
Now, what I would like is to create a button code that allows me to combine only the visible PDFs into a single PDF file, based on the example formula mentioned above. Does Ninox currently provide a similar function? Or is there an HTML code, app or an API function that allows me to do this for FREE on Mac? Or perhaps it's possible to integrate a call to Automator to merge the PDFs.
3 replies
-
Can someone help me?
-
UPDATE: I've created url fields in Ninox that I can use. Since the PDF attachment it refers can change beacuse maybe I have to change the pdf file, I can't take the static URL but I have to refer to the field. My problem now is that I need only != null urls to be considered to create the url
if length(URLarray) > 0 then URLarray := left(URLarray, length(URLarray) - 1) end;
This part gives me errors though. Maybe someone can help me on how to create the URLarray. The last url has to be without the comma on the end. The complete code is:
let x := for loop in numbers(Zertifikate) do record(Allegati, loop) end; let americana := count(x[Descrizione = "Americana"]) > 0; let bodenplatten := count(x[Descrizione = "Bodenplatten lackiert SAL"]) > 0; let dibond := count(x[Descrizione = "Dibond"]) > 0; let klebefolieGlaenzend := count(x[Descrizione = "Klebefolie & Klebeschrift (Glänzend)"]) > 0; let klebefolieMatt := count(x[Descrizione = "Klebefolie & Klebeschrift (Matt)"]) > 0; let elektroKettenzuege := count(x[Descrizione = "Elektro - Kettenzüge"]) > 0; let elektroZertifikat := count(x[Descrizione = "Elektro - Zertifikat"]) > 0; let forex := count(x[Descrizione = "Forex"]) > 0; let haengepunkte := count(x[Descrizione = "Hängepunkte"]) > 0; let klebefolieEN48 := count(x[Descrizione = "Klebefolie EN48 (nur auf schwarze Wände)"]) > 0; let lackGrundierung := count(x[Descrizione = "Lack Grundierung"]) > 0; let lackVerinlegno := count(x[Descrizione = "Lack Verinlegno"]) > 0; let laminatbodenOblige := count(x[Descrizione = "Laminatboden OBLIGE"]) > 0; let leuchtballonAirstar := count(x[Descrizione = "Leuchtballon Airstar"]) > 0; let linoleumPvcOne := count(x[Descrizione = "Linoleum PVC ONE"]) > 0; let pedaneMdfSalp := count(x[Descrizione = "Pedane MDF - SALP"]) > 0; let podesteBuetec := count(x[Descrizione = "Podeste Bütec"]) > 0; let polionda := count(x[Descrizione = "Polionda"]) > 0; let stoffBacklight := count(x[Descrizione = "Stoff Backlight"]) > 0; let stoffFlagFahnen := count(x[Descrizione = "Stoff Flag - Fahnen"]) > 0; let stoffPointexDanubio := count(x[Descrizione = "Stoff Pointex Danubio"]) > 0; let stoffWaendeMdf := count(x[Descrizione = "Stoff Wände MDF"]) > 0; let teppichAlma := count(x[Descrizione = "Teppich Alma"]) > 0; let teppichMontecolinoMagic := count(x[Descrizione = "Teppich Montecolino MAGIC"]) > 0; let teppichMontecolinoTrisSpagna := count(x[Descrizione = "Teppich Montecolino TRIS SPAGNA"]) > 0; let tuerenLaminat := count(x[Descrizione = "Türen Laminat"]) > 0; let vdsSprinklerNetzPointexRio := count(x[Descrizione = "VdS - Sprinkler Netz POINTEX RIO"]) > 0; let vdsSprinklerNetzRabenring := count(x[Descrizione = "VdS - Sprinkler Netz RABENRING"]) > 0; let waendeTuerenMdfSalp := count(x[Descrizione = "Wände und Türen MDF SALP"]) > 0; let urlAmericana := if americana then (select Allegati where ID = 1).URL else null end; let urlBodenplatten := if bodenplatten then (select Allegati where ID = 2).URL else null end; let urlDibond := if dibond then (select Allegati where ID = 3).URL else null end; let urlKlebefolieGlaenzend := if klebefolieGlaenzend then (select Allegati where ID = 9).URL else null end; let urlKlebefolieMatt := if klebefolieMatt then (select Allegati where ID = 10).URL else null end; let urlElektroKettenzuege := if elektroKettenzuege then (select Allegati where ID = 4).URL else null end; let urlElektroZertifikat := if elektroZertifikat then (select Allegati where ID = 5).URL else null end; let urlForex := if forex then (select Allegati where ID = 7).URL else null end; let urlHaengepunkte := if haengepunkte then (select Allegati where ID = 8).URL else null end; let urlKlebefolieEN48 := if klebefolieEN48 then (select Allegati where ID = 11).URL else null end; let urlLackGrundierung := if lackGrundierung then (select Allegati where ID = 12).URL else null end; let urlLackVerinlegno := if lackVerinlegno then (select Allegati where ID = 13).URL else null end; let urlLaminatbodenOblige := if laminatbodenOblige then (select Allegati where ID = 14).URL else null end; let urlLeuchtballonAirstar := if leuchtballonAirstar then (select Allegati where ID = 15).URL else null end; let urlLinoleumPvcOne := if linoleumPvcOne then (select Allegati where ID = 23).URL else null end; let urlPedaneMdfSalp := if pedaneMdfSalp then (select Allegati where ID = 16).URL else null end; let urlPodesteBuetec := if podesteBuetec then (select Allegati where ID = 17).URL else null end; let urlPolionda := if polionda then (select Allegati where ID = 18).URL else null end; let urlStoffBacklight := if stoffBacklight then (select Allegati where ID = 19).URL else null end; let urlStoffFlagFahnen := if stoffFlagFahnen then (select Allegati where ID = 6).URL else null end; let urlStoffPointexDanubio := if stoffPointexDanubio then (select Allegati where ID = 20).URL else null end; let urlStoffWaendeMdf := if stoffWaendeMdf then (select Allegati where ID = 21).URL else null end; let urlTeppichAlma := if teppichAlma then (select Allegati where ID = 22).URL else null end; let urlTeppichMontecolinoMagic := if teppichMontecolinoMagic then (select Allegati where ID = 24).URL else null end; let urlTeppichMontecolinoTrisSpagna := if teppichMontecolinoTrisSpagna then (select Allegati where ID = 26).URL else null end; let urlTuerenLaminat := if tuerenLaminat then (select Allegati where ID = 27).URL else null end; let urlVdsSprinklerNetzPointexRio := if vdsSprinklerNetzPointexRio then (select Allegati where ID = 28).URL else null end; let urlVdsSprinklerNetzRabenring := if vdsSprinklerNetzRabenring then (select Allegati where ID = 29).URL else null end; let urlWaendeTuerenMdfSalp := if waendeTuerenMdfSalp then (select Allegati where ID = 31).URL else null end; let URLarray := []; if urlAmericana then URLarray := URLarray + urlAmericana + "," end; if urlBodenplatten then URLarray := URLarray + urlBodenplatten + "," end; if urlDibond then URLarray := URLarray + urlDibond + "," end; if urlKlebefolieGlaenzend then URLarray := URLarray + urlKlebefolieGlaenzend + "," end; if urlKlebefolieMatt then URLarray := URLarray + urlKlebefolieMatt + "," end; if urlElektroKettenzuege then URLarray := URLarray + urlElektroKettenzuege + "," end; if urlElektroZertifikat then URLarray := URLarray + urlElektroZertifikat + "," end; if urlForex then URLarray := URLarray + urlForex + "," end; if urlHaengepunkte then URLarray := URLarray + urlHaengepunkte + "," end; if urlKlebefolieEN48 then URLarray := URLarray + urlKlebefolieEN48 + "," end; if urlLackGrundierung then URLarray := URLarray + urlLackGrundierung + "," end; if urlLackVerinlegno then URLarray := URLarray + urlLackVerinlegno + "," end; if urlLaminatbodenOblige then URLarray := URLarray + urlLaminatbodenOblige + "," end; if urlLeuchtballonAirstar then URLarray := URLarray + urlLeuchtballonAirstar + "," end; if urlLinoleumPvcOne then URLarray := URLarray + urlLinoleumPvcOne + "," end; if urlPedaneMdfSalp then URLarray := URLarray + urlPedaneMdfSalp + "," end; if urlPodesteBuetec then URLarray := URLarray + urlPodesteBuetec + "," end; if urlPolionda then URLarray := URLarray + urlPolionda + "," end; if urlStoffBacklight then URLarray := URLarray + urlStoffBacklight + "," end; if urlStoffFlagFahnen then URLarray := URLarray + urlStoffFlagFahnen + "," end; if urlStoffPointexDanubio then URLarray := URLarray + urlStoffPointexDanubio + "," end; if urlStoffWaendeMdf then URLarray := URLarray + urlStoffWaendeMdf + "," end; if urlTeppichAlma then URLarray := URLarray + urlTeppichAlma + "," end; if urlTeppichMontecolinoMagic then URLarray := URLarray + urlTeppichMontecolinoMagic + "," end; if urlTeppichMontecolinoTrisSpagna then URLarray := URLarray + urlTeppichMontecolinoTrisSpagna + "," end; if urlTuerenLaminat then URLarray := URLarray + urlTuerenLaminat + "," end; if urlVdsSprinklerNetzPointexRio then URLarray := URLarray + urlVdsSprinklerNetzPointexRio + "," end; if urlVdsSprinklerNetzRabenring then URLarray := URLarray + urlVdsSprinklerNetzRabenring + "," end; if urlWaendeTuerenMdfSalp then URLarray := URLarray + urlWaendeTuerenMdfSalp + "," end; if length(URLarray) > 0 then URLarray := left(URLarray, length(URLarray) - 1) end; html("<!DOCTYPE html> <html lang='en'> <head> <meta charset='UTF-8'> <meta name='viewport' content='width=device-width, initial-scale=1.0'> <title>Combine PDF Files from URLs</title> </head> <body> <button onclick='combinePDF()'>Combine PDF Files from URLs</button> <script src='https://cdnjs.cloudflare.com/ajax/libs/pdf-lib/1.16.0/pdf-lib.min.js'></script> <script> async function combinePDF() { const urls = [" + URLarray + "].filter(url => url !== 'null'); // Filtra gli URL nulli if (urls.length === 0) { alert('Nessun URL valido trovato.'); return; } const pdfDoc = await PDFLib.PDFDocument.create(); for (let i = 0; i < urls.length; i++) { const response = await fetch(urls[i]); const arrayBuffer = await response.arrayBuffer(); const tempPdfDoc = await PDFLib.PDFDocument.load(arrayBuffer); const copiedPages = await pdfDoc.copyPages(tempPdfDoc, tempPdfDoc.getPageIndices()); copiedPages.forEach((page) => pdfDoc.addPage(page)); } const pdfBytes = await pdfDoc.save(); const blob = new Blob([pdfBytes], { type: 'application/pdf' }); const url = URL.createObjectURL(blob); // Creare un link temporaneo per il download const a = document.createElement('a'); a.href = url; a.download = 'combined.pdf'; document.body.appendChild(a); a.click(); document.body.removeChild(a); // Messaggio per aprire il file con Safari alert('Il file PDF è stato creato. Se non si apre automaticamente, apri il file manualmente con Safari.'); } </script> </body> </html>
Next problem is that I can download the file if I use Ninox in Safari but in Ninox for Mac iI get an error because it can not open blob link.
Content aside
- 6 mths agoLast active
- 3Replies
- 78Views
-
1
Following