Can I export a PDF file from the QLIK SENSE API not through a link but directly so that a PDF file with the desired sheet will be attached?

I manage to export from the QLIK SENSE API sheets by sheet and application IDs, but first of all I have to click on a link that leads me to download the PDF file, I was unable to cancel the action of clicking on the link

I expect an attached PDF file to be sent to me through the QLIK SENSE API without having to click on a link

<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>Qlik Sense Mashup</title>
    <meta charset="utf-8">
    <script src="https://pa-qliksense.aviv.gov.il/sense/app/appId"></script>
    <meta http-equiv="content-type"="text/html; charset=UTF-8">
    <meta name="HandheldFriendly" content="True">
    <meta name="MobileOptimized" content="320">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta http-equiv="cleartype" content="on">
    <script src="../../resources/assets/external/requirejs/require.js"></script>
    <style>
        /* Spinner CSS */
        .spinner {
            border: 16px solid #f3f3f3;
            border-radius: 50%;
            border-top: 16px solid #3498db;
            width: 120px;
            height: 120px;
            animation: spin 2s linear infinite;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
        }

        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        #spinnerContainer {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(255, 255, 255, 0.8);
            z-index: 9999;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        #spinnerContainer.hidden {
            display: none;
        }
    </style>
</head>
<body style="overflow: auto">
    <div id="spinnerContainer">
        <div class="spinner"></div>
    </div>
    <div id="CurrentSelections" class="qvobjects" style="position:relative; top:0; left:0; width:100%; height:38px;"></div>
    <div id="downloadLinks" style="margin-top: 20px;"></div>

    <!-- Automatically trigger export on page load -->
    <script>
        window.onload = function () {
            var urlParams = new URLSearchParams(window.location.search);
            var appId = urlParams.get('appId');
            var sheetId = urlParams.get('sheetId');
            var fieldName1 = urlParams.get('fieldName1');
            var fieldValue1 = urlParams.get('fieldValue1');
            var fieldName2 = urlParams.get('fieldName2');
            var fieldValue2 = urlParams.get('fieldValue2');
            var fieldName3 = urlParams.get('fieldName3');
            var fieldValue3 = urlParams.get('fieldValue3');
            var fieldName4 = urlParams.get('fieldName4');
            var fieldValue4 = urlParams.get('fieldValue4');
            var fieldName5 = urlParams.get('fieldName5');
            var fieldValue5 = urlParams.get('fieldValue5');
            var fieldName6 = urlParams.get('fieldName6');
            var fieldValue6 = urlParams.get('fieldValue6');
            var fieldName7 = urlParams.get('fieldName7');
            var fieldValue7 = urlParams.get('fieldValue7');
            var fieldName8 = urlParams.get('fieldName8');
            var fieldValue8 = urlParams.get('fieldValue8');

            exportData(appId, sheetId, fieldName1, fieldValue1, fieldName2, fieldValue2, fieldName3, fieldValue3, fieldName4, fieldValue4, fieldName5, fieldValue5, fieldName6, fieldValue6, fieldName7, fieldValue7, fieldName8, fieldValue8);
        };

        function exportData(appId, sheetId, fieldName1, fieldValue1, fieldName2, fieldValue2, fieldName3, fieldValue3, fieldName4, fieldValue4, fieldName5, fieldValue5, fieldName6, fieldValue6, fieldName7, fieldValue7, fieldName8, fieldValue8) {
            var prefix = window.location.pathname.substr(0, window.location.pathname.toLowerCase().lastIndexOf("/extensions") + 1);
            var config = {
                host: window.location.hostname,
                prefix: prefix,
                port: window.location.port,
                isSecure: window.location.protocol === "https:"
            };

            require.config({
                baseUrl: (config.isSecure ? "https://" : "http://") + config.host + (config.port ? ":" + config.port : "") + config.prefix + "resources"
            });

            require(["js/qlik"], function (qlik) {
                qlik.setOnError(function (error) {
                    console.error('Error:', error);
                    alert('Error: ' + error.message);
                });
                qlik.theme.apply('horizon');

                // Open app
                var app = qlik.openApp(appId, config);

                // Clear all selections before applying new ones
                app.clearAll().then(function () {
                    // Apply selections
                    app.field(fieldName1).selectValues([fieldValue1], true, false);
                    app.field(fieldName2).selectValues([fieldValue2], true, false);
                    app.field(fieldName3).selectValues([fieldValue3], true, false);
                    app.field(fieldName4).selectValues([fieldValue4], true, false);
                    app.field(fieldName5).selectValues([fieldValue5], true, false);
                    app.field(fieldName6).selectValues([fieldValue6], true, false);
                    app.field(fieldName7).selectValues([fieldValue7], true, false);
                    app.field(fieldName8).selectValues([fieldValue8], true, false);

                    // Export entire sheet to PDF
                    app.visualization.get(sheetId).then(function (object) {
                        object.exportPdf({
                            documentSize: 'A4',
                            aspectRatio: 0,
                            orientation: "landscape",
                            objectSize: { height: 1280, width: 1920 }
                        }).then(function (pdfExportData) {
                            // Hide spinner
                            document.getElementById('spinnerContainer').classList.add('hidden');
                            // Create an invisible link element
                            var link = document.createElement('a');
                            link.href = pdfExportData;
                            link.download = 'exported_dashboard.pdf';
                            link.style.display = 'none';
                            document.body.appendChild(link);
                            // Trigger the download by clicking the link
                            link.click();
                            // Remove the link element from the document
                            document.body.removeChild(link);
                        }).catch(function (pdfError) {
                            console.error('Error exporting dashboard to PDF:', pdfError);
                            alert('Error exporting dashboard to PDF. See console for details.');
                            document.getElementById('spinnerContainer').classList.add('hidden');
                        });
                    }).catch(function (error) {
                        console.error('Error getting current selections object:', error);
                        alert('Error getting current selections object. See console for details.');
                        document.getElementById('spinnerContainer').classList.add('hidden');
                    });
                }).catch(function (error) {
                    console.error('Error clearing selections:', error);
                    alert('Error clearing selections. See console for details.');
                    document.getElementById('spinnerContainer').classList.add('hidden');
                });
            });
        }
    </script>
</body>
</html>

New contributor

Neomi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật