Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to show progress bar in one line when using for loop ? #159

Open
amrsa1 opened this issue Oct 2, 2024 · 2 comments
Open

How to show progress bar in one line when using for loop ? #159

amrsa1 opened this issue Oct 2, 2024 · 2 comments

Comments

@amrsa1
Copy link

amrsa1 commented Oct 2, 2024

I have a function where im looping over an array, to do some process this lead to see progress bar appearing in many line rather than show the progress on the same bar.

Could you provide an example how to do so when im using for loop

const bar = new cliProgress.SingleBar({
      format: 'Processing |' + chalk.cyan('{bar}') + '| {percentage}% || {value}/{total} Pages || Current File: {filename}',
      barCompleteChar: '\u2588',
      barIncompleteChar: '\u2591',
      hideCursor: true
    }, cliProgress.Presets.shades_classic);

    bar.start(pages.length, 0, {
      filename: 'Starting...'
    });

    for (const page of pages) {
      const pageName = page.FileLeafRef;

      // Update the progress bar with the current file name and progress
      bar.increment(1, {
        filename: pageName
      });

      const pageContent = page.CanvasContent1;

      if (pageContent) {
        const cleanedContent = cleanHtml(decodedContent);
        const outputPdfPath = `./${path.parse(pageName).name}.pdf`;
        await convertHtmlToPdf(cleanedContent, outputPdfPath);
      } else {
        console.log(chalk.red(`Failed to retrieve content for page: ${pageName}\n`));
      }
@Bryanpablo-GSA
Copy link

Hi, did you find a fix for this issue? I'm currently running into the same thing. Thanks.

@AndiDittrich
Copy link
Member

mostly caused by some logs/stdout/stderr writes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants