npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@muzammil931/pdf-pages-rotation

v1.0.2

Published

+ Recommended library to render/display pdf pages is, [react-pdf](https://github.com/wojtekmaj/react-pdf/blob/main/packages/react-pdf/README.md). You can also use anyother pdf library as well in order to render your pdf.

Downloads

1

Readme

PreRequisites:

  • Recommended library to render/display pdf pages is, react-pdf. You can also use anyother pdf library as well in order to render your pdf.

  • You can also use iframe tag to render the url that the below functions will return.

  • For complete Project which includes react-pdf implementation as well. Please follow this github:

Github/MuzammilIrshad

Getting Started

Step 01:

npm i @muzammil931/pdf-pages-rotation

Step 02:

import {ExtractPdfPages, RotatePdfPage} from '@muzammil931/pdf-pages-rotation'

In this import, ExtractPdfPages function takes argument event and returns back a url which you can use to render your pdf.

The RotatePdfPage1 function takes event as well as an array of numbers as arguments. The event will contain pdf file and array of numbers will contain all those page numbers on which user has clicked on and changed their rotation. So that user can rotate multiple pdf pagess, instead of one at a time.

Step 03:

const pagesAlreadyRotated = [] //stores page numbers of pages that are already rotated.
let pdfFileUrl = '' // stores url of pdf to render pdf in browser
let event = '' // stores event which contains user selected pdf file

  const onFileSelection = async (e) => {
    const { files } = e.target;
    event = e;
         const url = await ExtractPdfPages(e);
         pdfFileUrl = url
  };

This function is an onChange function and whenever the pdf input tag will change, this function will be called and a url will be given, which will contain all pdf pages in a single form.

async function handleRotation (pageNumber){

  const numOfPagesRotated = [...pagesAlreadyRotated, pageNumber]
  const url = await RotatePdfPage(event, numOfPagesRotated);
  pdfFileUrl = url
  <!--
   Logic to show user a rotated page on frontend.
    For example: A logic which will rotate the div in which page is being displayed or to download the updated file. Simply add this:

    // Create a hidden anchor element
    const link = document.createElement('a');
    link.href = pdfFileUrl;
    link.download = 'document.pdf'; // You can specify the filename here
    link.style.display = 'none';

    // Append the anchor element to the document
    document.body.appendChild(link);

    // Simulate a click event to trigger the download
    link.click();

    // Clean up: remove the anchor element and revoke the Blob URL
    document.body.removeChild(link);
    URL.revokeObjectURL(pdfFileUrl);
   -->
}

The handleRotation function will return the url of updated pdf which will contain the pages that user rotated, alongside rest of the pages.