Step 2: Activate Dynamsoft Document Viewer

  1. In index.html, create an input element for the license key and a button to activate the SDK:

  2. Implement the activation logic in main.js:

    async function activate(license) {    try {        Dynamsoft.DDV.Core.license = license;        Dynamsoft.DDV.Core.engineResourcePath = \\\"https://cdn.jsdelivr.net/npm/[email protected]/dist/engine\\\";        await Dynamsoft.DDV.Core.init();        Dynamsoft.DDV.setProcessingHandler(\\\"imageFilter\\\", new Dynamsoft.DDV.ImageFilter());        docManager = Dynamsoft.DDV.documentManager;    } catch (error) {        console.error(error);        toggleLoading(false);    }}

    Explanation

Step 3: Create a Web PDF Viewer with Ready-to-Use Components

The Dynamsoft Document Viewer SDK provides a built-in document editor that requires minimal code to construct a web PDF viewer application.

  1. Create a container element for the document viewer in index.html:

  2. Initialize the document viewer in main.js:

    async function showViewer() {    if (!docManager) return;    let editContainer = document.getElementById(\\\"edit-viewer\\\");    editContainer.parentNode.style.display = \\\"block\\\";    editViewer = new Dynamsoft.DDV.EditViewer({        container: editContainer,        uiConfig: DDV.getDefaultUiConfig(\\\"editViewer\\\", { includeAnnotationSet: true })    });}

    The uiConfig parameter specifies the default UI configuration for the document viewer, including annotation tools.

Step 4: Add a Custom Button to Insert Barcodes into the PDF Document

Dynamsoft Document Viewer allows for customization of UI elements and event handlers. According to the official documentation, you can add custom buttons.

A Custom Barcode Button with Google\\'s Material Icons

Define a custom button object in main.js:

const qrButton = {    type: Dynamsoft.DDV.Elements.Button,    className: \\\"material-icons icon-qr_code\\\",    tooltip: \\\"Add a QR code. Ctrl Q\\\",    events: {        click: \\\"addQr\\\",    },};

The className points to Google fonts. Use the material-icons class to display the qr_code icon in the button.

Add the Barcode Button to the Toolbar

To add the button to the toolbar, modify the uiConfig parameter in the showViewer function:

const pcEditViewerUiConfig = {    type: Dynamsoft.DDV.Elements.Layout,    flexDirection: \\\"column\\\",    className: \\\"ddv-edit-viewer-desktop\\\",    children: [        {            type: Dynamsoft.DDV.Elements.Layout,            className: \\\"ddv-edit-viewer-header-desktop\\\",            children: [                {                    type: Dynamsoft.DDV.Elements.Layout,                    children: [                        Dynamsoft.DDV.Elements.ThumbnailSwitch,                        Dynamsoft.DDV.Elements.Zoom,                        Dynamsoft.DDV.Elements.FitMode,                        Dynamsoft.DDV.Elements.DisplayMode,                        Dynamsoft.DDV.Elements.RotateLeft,                        Dynamsoft.DDV.Elements.RotateRight,                        Dynamsoft.DDV.Elements.Crop,                        Dynamsoft.DDV.Elements.Filter,                        Dynamsoft.DDV.Elements.Undo,                        Dynamsoft.DDV.Elements.Redo,                        Dynamsoft.DDV.Elements.DeleteCurrent,                        Dynamsoft.DDV.Elements.DeleteAll,                        Dynamsoft.DDV.Elements.Pan,                        Dynamsoft.DDV.Elements.AnnotationSet,                        qrButton,                    ],                },                {                    type: Dynamsoft.DDV.Elements.Layout,                    children: [                        {                            type: Dynamsoft.DDV.Elements.Pagination,                            className: \\\"ddv-edit-viewer-pagination-desktop\\\",                        },                        Dynamsoft.DDV.Elements.Load,                        {                            type: Dynamsoft.DDV.Elements.Button,                            className: \\\"ddv-button ddv-button-download\\\",                            events: {                                click: \\\"download\\\",                            }                        }                    ],                },            ],        },        Dynamsoft.DDV.Elements.MainView,    ],};editViewer = new Dynamsoft.DDV.EditViewer({    container: editContainer,    uiConfig: pcEditViewerUiConfig});

Press the Button to Pop Up a Barcode Generation Dialog

When the barcode button is clicked, a pop-up dialog will appear for users to input the barcode content and select the barcode type:

editViewer.on(\\\"addQr\\\", addQr);

The dialog contains the following elements:

Here\\'s the full code:

Step 5: Generate a Barcode and Insert it as Annotation to PDF Document

Include the bwip-js library in index.html. This library is used to generate barcodes in various formats, such as QR Code, PDF417, and DataMatrix.

After retrieving the barcode content and type, use bwipjs to draw the generated barcode on a canvas. Then, convert the canvas to a blob and insert it as an annotation to the PDF document.

if (barcodeContent !== null) {    try {        bwipjs.toCanvas(tempCanvas, {            bcid: barcodeType,            text: barcodeContent,            scale: 3,            includetext: false,        });        tempCanvas.toBlob(async (blob) => {            if (blob) {                let currentPageId = docs[0].pages[editViewer.getCurrentPageIndex()];                let pageData = await docs[0].getPageData(currentPageId);                const option = {                    stamp: blob,                    x: pageData.mediaBox.width - 110,                    y: 10,                    width: 100,                    height: 100,                    opacity: 1.0,                    flags: {                        print: false,                        noView: false,                        readOnly: false,                    }                }                if (applyToAllPages) {                    for (let i = 0; i < docs[0].pages.length; i  ) {                        await Dynamsoft.DDV.annotationManager.createAnnotation(docs[0].pages[i], \\\"stamp\\\", option)                    }                } else {                    await Dynamsoft.DDV.annotationManager.createAnnotation(currentPageId, \\\"stamp\\\", option)                }            }        }, \\'image/png\\');    } catch (e) {        console.log(e);    }}

Step 6: Save the PDF Document with Barcodes to Local Disk

Create a download() function and bind it to the download button in the toolbar:

editViewer.on(\\\"download\\\", download);async function download() {    try {        const pdfSettings = {            saveAnnotation: \\\"flatten\\\",        };        let blob = await editViewer.currentDocument.saveToPdf(pdfSettings);        saveBlob(blob, `document_${Date.now()}.pdf`);    } catch (error) {        console.log(error);    }}function saveBlob(blob, fileName) {    const url = URL.createObjectURL(blob);    const a = document.createElement(\\'a\\');    a.href = url;    a.download = fileName;    document.body.appendChild(a);    a.click();    document.body.removeChild(a);    URL.revokeObjectURL(url);}

When saving the PDF document, the saveAnnotation option is set to flatten, ensuring that annotations, including the barcodes, are embedded in the document.

Running the Web PDF Document Editor

  1. Start a web server in the root directory of your project:

    python -m http.server
  2. Open http://localhost:8000 in your web browser.

  3. Load a PDF document.

  4. Insert a barcode as an annotation into the PDF document.

    \\\"How

Reading Barcodes from PDF Documents

Once the PDF document is saved to your local disk, you can verify the barcode content by reading it with the Dynamsoft Barcode Reader.

  1. Install barcode4nodejs, a Node.js wrapper built with the Dynamsoft C Barcode Reader SDK.

    npm i barcode4nodejs
  2. Create a script file, test.js, to read barcodes from the PDF document:

    var dbr = require(\\'barcode4nodejs\\');var barcodeTypes = dbr.formats.ALL;dbr.initLicense(\\\"LICENSE-KEY\\\");let args = process.argv;if (args.includes(\\'-f\\')) {  let fIndex = args.indexOf(\\'-f\\');  if (args[fIndex   1]) {    (async function () {      try {        var result = await dbr.decodeFileAsync(args[fIndex   1], barcodeTypes, \\\"\\\");        console.log(result);        setTimeout(() => {          console.log(\\'terminated\\');        }, 1000);      } catch (error) {        console.log(error);      }    })();  } else {    console.log(\\'Please add a file.\\');  }}

    Note: You need to replace the LICENSE-KEY with your own.

  3. Run the script with the path to a PDF file:

    node test.js -f 

    The barcode content will be printed in the console.

    \\\"How

Source Code

https://github.com/yushulx/web-twain-document-scan-management/tree/main/examples/document_annotation

","image":"http://www.luping.net/uploads/20241119/1731991338673c172aa2afc.png","datePublished":"2024-11-19T13:47:08+08:00","dateModified":"2024-11-19T13:47:08+08:00","author":{"@type":"Person","name":"luping.net","url":"https://www.luping.net/articlelist/0_1.html"}}
」工欲善其事,必先利其器。「—孔子《論語.錄靈公》

如何使用 HTMLnd JavaScript 將條碼插入 PDF 文檔

發佈於2024-11-19
瀏覽:210

Inserting barcodes into PDF documents can significantly streamline document management, tracking, and data processing workflows. Barcodes serve as unique identifiers, enabling automated data entry, quick retrieval, and enhanced security. In this article, we'll demonstrate how to leverage HTML5, JavaScript, and the Dynamsoft Document Viewer SDK to generate and embed barcodes into PDF documents.

Web PDF Editor Demo Video

Online Demo

https://yushulx.me/web-document-annotation/

Prerequisites

  • Dynamsoft Document Viewer: This JavaScript SDK allows for seamless viewing and annotation of various document formats, including PDFs and common image files such as JPEG, PNG, TIFF, and BMP. With its robust feature set, you can render PDFs, navigate pages, enhance image quality, and save annotated documents. Install the package from npm to get started.

  • Dynamsoft Capture Vision Trial License: To access the full capabilities of the Dynamsoft SDKs, sign up for a 30-day free trial license. This trial offers complete access to all features, enabling you to explore the SDKs in-depth.

Steps to Implement a PDF Document Editor in HTML5 and JavaScript

In the following paragraphs, we'll walk you through the process of creating a web-based PDF document editor with barcode insertion capabilities. The editor will enable users to load PDF documents, insert barcodes as annotations, and save the modified PDF files locally.

Step 1: Include the Dynamsoft Document Viewer SDK

In the

section of your HTML file, add the following script tags to include the Dynamsoft Document Viewer SDK:

Step 2: Activate Dynamsoft Document Viewer

  1. In index.html, create an input element for the license key and a button to activate the SDK:

  2. Implement the activation logic in main.js:

    async function activate(license) {
        try {
            Dynamsoft.DDV.Core.license = license;
            Dynamsoft.DDV.Core.engineResourcePath = "https://cdn.jsdelivr.net/npm/[email protected]/dist/engine";
            await Dynamsoft.DDV.Core.init();
            Dynamsoft.DDV.setProcessingHandler("imageFilter", new Dynamsoft.DDV.ImageFilter());
            docManager = Dynamsoft.DDV.documentManager;
    
        } catch (error) {
            console.error(error);
            toggleLoading(false);
        }
    
    }
    

    Explanation

    • The engineResourcePath must point to the location of the Dynamsoft Document Viewer engine files.
    • setProcessingHandler sets the image filter for enhancing image quality.
    • The documentManager object is used to manage the document viewer and editor.

Step 3: Create a Web PDF Viewer with Ready-to-Use Components

The Dynamsoft Document Viewer SDK provides a built-in document editor that requires minimal code to construct a web PDF viewer application.

  1. Create a container element for the document viewer in index.html:

  2. Initialize the document viewer in main.js:

    async function showViewer() {
        if (!docManager) return;
        let editContainer = document.getElementById("edit-viewer");
        editContainer.parentNode.style.display = "block";
        editViewer = new Dynamsoft.DDV.EditViewer({
            container: editContainer,
            uiConfig: DDV.getDefaultUiConfig("editViewer", { includeAnnotationSet: true })
        });
    }
    

    The uiConfig parameter specifies the default UI configuration for the document viewer, including annotation tools.

  3. Step 4: Add a Custom Button to Insert Barcodes into the PDF Document

    Dynamsoft Document Viewer allows for customization of UI elements and event handlers. According to the official documentation, you can add custom buttons.

    A Custom Barcode Button with Google's Material Icons

    Define a custom button object in main.js:

    const qrButton = {
        type: Dynamsoft.DDV.Elements.Button,
        className: "material-icons icon-qr_code",
        tooltip: "Add a QR code. Ctrl Q",
        events: {
            click: "addQr",
        },
    };
    

    The className points to Google fonts. Use the material-icons class to display the qr_code icon in the button.

    Add the Barcode Button to the Toolbar

    To add the button to the toolbar, modify the uiConfig parameter in the showViewer function:

    const pcEditViewerUiConfig = {
        type: Dynamsoft.DDV.Elements.Layout,
        flexDirection: "column",
        className: "ddv-edit-viewer-desktop",
        children: [
            {
                type: Dynamsoft.DDV.Elements.Layout,
                className: "ddv-edit-viewer-header-desktop",
                children: [
                    {
                        type: Dynamsoft.DDV.Elements.Layout,
                        children: [
                            Dynamsoft.DDV.Elements.ThumbnailSwitch,
                            Dynamsoft.DDV.Elements.Zoom,
                            Dynamsoft.DDV.Elements.FitMode,
                            Dynamsoft.DDV.Elements.DisplayMode,
                            Dynamsoft.DDV.Elements.RotateLeft,
                            Dynamsoft.DDV.Elements.RotateRight,
                            Dynamsoft.DDV.Elements.Crop,
                            Dynamsoft.DDV.Elements.Filter,
                            Dynamsoft.DDV.Elements.Undo,
                            Dynamsoft.DDV.Elements.Redo,
                            Dynamsoft.DDV.Elements.DeleteCurrent,
                            Dynamsoft.DDV.Elements.DeleteAll,
                            Dynamsoft.DDV.Elements.Pan,
                            Dynamsoft.DDV.Elements.AnnotationSet,
                            qrButton,
                        ],
                    },
                    {
                        type: Dynamsoft.DDV.Elements.Layout,
                        children: [
                            {
                                type: Dynamsoft.DDV.Elements.Pagination,
                                className: "ddv-edit-viewer-pagination-desktop",
                            },
                            Dynamsoft.DDV.Elements.Load,
                            {
                                type: Dynamsoft.DDV.Elements.Button,
                                className: "ddv-button ddv-button-download",
                                events: {
                                    click: "download",
                                }
                            }
                        ],
                    },
                ],
            },
            Dynamsoft.DDV.Elements.MainView,
        ],
    };
    
    editViewer = new Dynamsoft.DDV.EditViewer({
        container: editContainer,
        uiConfig: pcEditViewerUiConfig
    });
    
    

    Press the Button to Pop Up a Barcode Generation Dialog

    When the barcode button is clicked, a pop-up dialog will appear for users to input the barcode content and select the barcode type:

    editViewer.on("addQr", addQr);
    

    The dialog contains the following elements:

    • A dropdown list for selecting barcode types.
    • An input field for entering barcode content.
    • An OK button to submit the data.
    • A Cancel button to close the pop-up without submitting.

    Here's the full code:

    Step 5: Generate a Barcode and Insert it as Annotation to PDF Document

    Include the bwip-js library in index.html. This library is used to generate barcodes in various formats, such as QR Code, PDF417, and DataMatrix.

    After retrieving the barcode content and type, use bwipjs to draw the generated barcode on a canvas. Then, convert the canvas to a blob and insert it as an annotation to the PDF document.

    if (barcodeContent !== null) {
        try {
    
            bwipjs.toCanvas(tempCanvas, {
                bcid: barcodeType,
                text: barcodeContent,
                scale: 3,
                includetext: false,
            });
    
            tempCanvas.toBlob(async (blob) => {
                if (blob) {
                    let currentPageId = docs[0].pages[editViewer.getCurrentPageIndex()];
                    let pageData = await docs[0].getPageData(currentPageId);
    
                    const option = {
                        stamp: blob,
                        x: pageData.mediaBox.width - 110,
                        y: 10,
                        width: 100,
                        height: 100,
                        opacity: 1.0,
                        flags: {
                            print: false,
                            noView: false,
                            readOnly: false,
    
                        }
                    }
    
                    if (applyToAllPages) {
                        for (let i = 0; i 
    
    
    
    

    Step 6: Save the PDF Document with Barcodes to Local Disk

    Create a download() function and bind it to the download button in the toolbar:

    editViewer.on("download", download);
    
    async function download() {
        try {
            const pdfSettings = {
                saveAnnotation: "flatten",
            };
    
            let blob = await editViewer.currentDocument.saveToPdf(pdfSettings);
    
            saveBlob(blob, `document_${Date.now()}.pdf`);
        } catch (error) {
            console.log(error);
        }
    
    }
    
    function saveBlob(blob, fileName) {
        const url = URL.createObjectURL(blob);
        const a = document.createElement('a');
        a.href = url;
        a.download = fileName;
        document.body.appendChild(a);
        a.click();
        document.body.removeChild(a);
        URL.revokeObjectURL(url);
    }
    

    When saving the PDF document, the saveAnnotation option is set to flatten, ensuring that annotations, including the barcodes, are embedded in the document.

    Running the Web PDF Document Editor

    1. Start a web server in the root directory of your project:

      python -m http.server
      
    2. Open http://localhost:8000 in your web browser.

    3. Load a PDF document.

    4. Insert a barcode as an annotation into the PDF document.

      How to Insert Barcodes into a PDF Document with HTMLnd JavaScript

    Reading Barcodes from PDF Documents

    Once the PDF document is saved to your local disk, you can verify the barcode content by reading it with the Dynamsoft Barcode Reader.

    1. Install barcode4nodejs, a Node.js wrapper built with the Dynamsoft C Barcode Reader SDK.

      npm i barcode4nodejs
      
    2. Create a script file, test.js, to read barcodes from the PDF document:

      var dbr = require('barcode4nodejs');
      var barcodeTypes = dbr.formats.ALL;
      
      dbr.initLicense("LICENSE-KEY");
      
      let args = process.argv;
      if (args.includes('-f')) {
        let fIndex = args.indexOf('-f');
        if (args[fIndex   1]) {
          (async function () {
            try {
              var result = await dbr.decodeFileAsync(args[fIndex   1], barcodeTypes, "");
              console.log(result);
              setTimeout(() => {
                console.log('terminated');
              }, 1000);
            } catch (error) {
              console.log(error);
            }
          })();
        } else {
          console.log('Please add a file.');
        }
      
      }
      

      Note: You need to replace the LICENSE-KEY with your own.

    3. Run the script with the path to a PDF file:

      node test.js -f 

      The barcode content will be printed in the console.

      How to Insert Barcodes into a PDF Document with HTMLnd JavaScript

    Source Code

    https://github.com/yushulx/web-twain-document-scan-management/tree/main/examples/document_annotation

版本聲明 本文轉載於:https://dev.to/yushulx/how-to-insert-barcodes-into-a-pdf-document-with-html5-and-javascript-32g9?1如有侵犯,請聯絡study_golang@163 .com刪除
最新教學 更多>
  • 如何模擬 Python 的請求模組以實現真實的 API 互動?
    如何模擬 Python 的請求模組以實現真實的 API 互動?
    模擬API 互動的模擬Python 請求模組在我們全面測試與API 互動的Python 程式碼的過程中,有效地模擬requests模組至關重要。以下是使用自訂回應模擬requests.get() 呼叫的逐步方法:第1 步:模擬Requests 模組利用Python 的模擬包,我們定義自訂函數(moc...
    程式設計 發佈於2024-11-19
  • ## 淘汰視圖模型:物件文字或函數 - 哪一個適合您?
    ## 淘汰視圖模型:物件文字或函數 - 哪一個適合您?
    KO 視圖模型:物件文字與函數在 Knockout JS 中,可以使用物件文字或函數來宣告視圖模型。雖然兩者的主要目的都是定義可觀察的屬性和計算函數,但它們之間的關鍵差異會影響封裝、靈活性和程式碼組織。 物件文字:var viewModel = { firstname: ko.observa...
    程式設計 發佈於2024-11-19
  • 為什麼我們應該避免在 MySQL 腳本中使用「SET NAMES」?
    為什麼我們應該避免在 MySQL 腳本中使用「SET NAMES」?
    使用「SET NAMES」的注意事項在MySQL資料庫處理的上下文中,「SET NAMES」的正確使用一直是討論的議題。正如 O'Reilly 的《高效能 MySQL》中所述,在腳本開頭使用「SET NAMES UTF8」的做法因其效率低下而受到質疑。 Unicode 感知資料庫的最佳實務工...
    程式設計 發佈於2024-11-19
  • 如何確保 MySQL 表是使用 Hibernate 使用 InnoDB 引擎建立的?
    如何確保 MySQL 表是使用 Hibernate 使用 InnoDB 引擎建立的?
    如何使用Hibernate 建立MySQL InnoDB 表當使用Hibernate 和JPA 時,使用者在使用InnoDB 建立MySQL 表時經常遇到挑戰引擎而不是MyISAM。為了解決這個問題,一個廣泛推薦的解決方案是透過設定 hibernate.dialect 屬性來配置 Hibernate...
    程式設計 發佈於2024-11-19
  • 大批
    大批
    方法是可以在物件上呼叫的 fns 數組是對象,因此它們在 JS 中也有方法。 slice(begin):將陣列的一部分提取到新數組中,而不改變原始數組。 let arr = ['a','b','c','d','e']; // Usecase: Extract till index ...
    程式設計 發佈於2024-11-19
  • 使用子類別物件的超類別引用
    使用子類別物件的超類別引用
    考慮一個場景,我們創建一個名為 User 的類,然後創建一個擴展 User 的子類,名為 Employee。 通常,我們會使用以下內容來建立 User 的實例: User user = new User(); 這裡User是變數user的型別,user是保存類別實例的變量,new User()建立...
    程式設計 發佈於2024-11-19
  • 如何在 Go 中不阻塞地檢查 Stdin 中的資料?
    如何在 Go 中不阻塞地檢查 Stdin 中的資料?
    使用 Go 檢查 Stdin 中的資料在 Go 中,在使用命令和管道時,與標準輸入 (stdin) 互動通常是一項關鍵任務。然而,在不阻塞程序執行的情況下確定 stdin 是否有數據可能具有挑戰性。 os.Stdin 檔案物件代表 stdin,它擁有與 Go 中其他檔案物件類似的功能。這使我們能夠利...
    程式設計 發佈於2024-11-19
  • 什麼時候應該在 JavaScript 中使用 const:優化程式碼還是過度使用?
    什麼時候應該在 JavaScript 中使用 const:優化程式碼還是過度使用?
    JavaScript 中的Const:優化程式碼效能並促進語義清晰度在JavaScript 中,const 關鍵字的引入引發了關於其最優值的討論用法。雖然它可能看起來與 var 關鍵字類似,但使用 const 有明顯的優勢,可以提高程式碼效率並提高語義精度。 const 何時適合? const 的...
    程式設計 發佈於2024-11-19
  • 何時應為特殊情況保留例外?
    何時應為特殊情況保留例外?
    例外:為特殊情況保留儘管例外很普遍,但通常還是提倡保守地使用例外。深入研究這一哲學背後的原因揭示了無數的考慮因素。 語意濫用為真正特殊情況而設計的異常經常被誤用為控制流機制。這破壞了它們的預期語義功能,因為預計不會引發異常來回應可預見的事件,例如不正確的使用者輸入。 異常處理的負擔異常破壞正常的執行...
    程式設計 發佈於2024-11-19
  • 如何在 PHP 中組合兩個關聯數組,同時保留唯一 ID 並處理重複名稱?
    如何在 PHP 中組合兩個關聯數組,同時保留唯一 ID 並處理重複名稱?
    在 PHP 中組合關聯數組在 PHP 中,將兩個關聯數組組合成一個數組是常見任務。考慮以下請求:問題描述:提供的代碼定義了兩個關聯數組,$array1 和 $array2。目標是建立一個新陣列 $array3,它合併兩個陣列中的所有鍵值對。 此外,提供的陣列具有唯一的 ID,而名稱可能重疊。要求是建...
    程式設計 發佈於2024-11-19
  • CSS 和 Javascript 程式碼應該放在 HTML 網頁中的什麼位置?
    CSS 和 Javascript 程式碼應該放在 HTML 網頁中的什麼位置?
    在HTML網頁中實作CSS和Javascript程式碼在Web開發過程中,確定CSS和Javascript程式碼的適當放置位置至關重要。這些文件在設計網頁樣式和增強網頁功能方面發揮著重要作用。當遇到諸如 之類的程式碼時,了解其在 HTML 文件中的預期位置非常重要。 放置選項在 HTML 文件中包...
    程式設計 發佈於2024-11-19
  • 在 Go 中使用 WebSocket 進行即時通信
    在 Go 中使用 WebSocket 進行即時通信
    构建需要实时更新的应用程序(例如聊天应用程序、实时通知或协作工具)需要比传统 HTTP 更快、更具交互性的通信方法。这就是 WebSockets 发挥作用的地方!今天,我们将探讨如何在 Go 中使用 WebSocket,以便您可以向应用程序添加实时功能。 在这篇文章中,我们将介绍: WebSocke...
    程式設計 發佈於2024-11-19
  • 如何使用 Pandas 解析分號分隔的 CSV 檔案?
    如何使用 Pandas 解析分號分隔的 CSV 檔案?
    使用Pandas 解析分號分隔的.CSV 檔案處理逗號分隔值(CSV) 檔案時,正確處理至關重要分隔符以確保準確的資料解析。 Pandas 提供了一種簡單的解決方案,用於讀取具有非標準分隔符號(例如分號)的 CSV 檔案。 考慮這個情況:您有一個格式類似於以下內容的 .csv 檔案:a1;b1;c1...
    程式設計 發佈於2024-11-19
  • Bootstrap 4 Beta 中的列偏移發生了什麼事?
    Bootstrap 4 Beta 中的列偏移發生了什麼事?
    Bootstrap 4 Beta:列偏移的刪除和恢復Bootstrap 4 在其Beta 1 版本中引入了重大更改柱子偏移了。然而,隨著 Beta 2 的後續發布,這些變化已經逆轉。 從 offset-md-* 到 ml-auto在 Bootstrap 4 Beta 1 中, offset-md-*...
    程式設計 發佈於2024-11-19
  • ENUM 是 MySQL 中有限值的最佳選擇嗎?
    ENUM 是 MySQL 中有限值的最佳選擇嗎?
    MySQL ENUM 效能注意事項在某些情況下使用 ENUM 可能會影響效能。雖然它在強制資料完整性方面提供了好處,但也存在需要考慮的潛在缺點。 特定操作的效能懲罰處理數量有限的欄位時可能的值 (5-10),ENUM 可能無法提供效能優勢。事實上,這可能會對某些操作產生顯著的負面影響,例如:查詢允許...
    程式設計 發佈於2024-11-19

免責聲明: 提供的所有資源部分來自互聯網,如果有侵犯您的版權或其他權益,請說明詳細緣由並提供版權或權益證明然後發到郵箱:[email protected] 我們會在第一時間內為您處理。

Copyright© 2022 湘ICP备2022001581号-3