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

I want o set both orientation in same pdf #691

Open
Siddhesh220398 opened this issue Apr 4, 2024 · 0 comments
Open

I want o set both orientation in same pdf #691

Siddhesh220398 opened this issue Apr 4, 2024 · 0 comments

Comments

@Siddhesh220398
Copy link

Siddhesh220398 commented Apr 4, 2024

Hi,
I want to add both orientation portrait and landscape in same pdf but it's not working. Can you help me out how to set opt on every page. Below I had share code.

const downloadPDF2 = (elements, pdfOptions) => {

      let worker = html2pdf()
        .set(pdfOptions)
        .from(elements[0])

      if (elements.length > 1) {
        worker = worker.toPdf() // worker is now a jsPDF instance

        // add each element/page individually to the PDF render process
        elements.slice(1).forEach((element, index) => {
          worker = worker
            .get('pdf')
            .then(pdf => {
              pdf.addPage()
            })
            .from(element)
            .toContainer()
            .toCanvas()
            .toPdf()
        })
      }

      worker = worker.save().then(
        function (pdf) {
            $('body').find('.process-div').html('');
            $('body').find('.btn-d').css('display','inline');
        },
         function(){
            $('body').find('.process-div').html('PDF Genration Fail Please Try Again!');
            $('body').find('.btn-d').css('display','inline');
        }).catch(function (error) {
            console.log(error);
            /* This is fired when the promise executes without the DOM */
        });
    }
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

1 participant