Code Monkey home page Code Monkey logo

Comments (12)

rkusa avatar rkusa commented on August 16, 2024

Hi, I've this requirement, too. However it is not possible, yet. I am currently working on major improvements and this feature is on my list. But I've no ETA.

from pdfjs.

ChrisMulvay avatar ChrisMulvay commented on August 16, 2024

Thanks for your reply. It would be a great and valued addition as at this time I cannot find a solution.

from pdfjs.

rkusa avatar rkusa commented on August 16, 2024

@jsNifty Do you want to add whole sides from an existing PDF file, or embed PDFs like images?

from pdfjs.

ChrisMulvay avatar ChrisMulvay commented on August 16, 2024

It would be excellent to be able to insert PDFs like you would insert images. There could be more than one PDF to embed in any one document.

from pdfjs.

rkusa avatar rkusa commented on August 16, 2024

I've implemented this feature in the current dev branch. However, this branch is highly unstable. After some cleanup and further testing in the next couple of days, I'll provide a test snippet for PDF embedding.

from pdfjs.

ChrisMulvay avatar ChrisMulvay commented on August 16, 2024

This is excellent! I look forward to working with this feature in the near future.
Thanks!!

from pdfjs.

rkusa avatar rkusa commented on August 16, 2024

Would you mind testing the PDF embedding?

You'll have to use the dev branch. Example snippet:

var pdfjs = require('./')
var path = require('path')
var fs = require('fs')

var regular = pdfjs.createTTFFont(
  fs.readFileSync(path.join(__dirname, 'test/fixtures/font/opensans/regular.ttf' ))
)

var doc = pdfjs.createDocument({
  font: regular
})

var img = pdfjs.createImage(
  fs.readFileSync(path.join(__dirname, 'logo/pdfjs.pdf' ))
)
doc.image(img)

var pdf = doc.render()
fs.writeFileSync(path.join(__dirname, 'pdf.pdf'), pdf.toString(), 'binary')

It is quite likely that you'll get an error. If so, I would highly appreciate if you could send me the PDF that fails.

Thanks

from pdfjs.

ChrisMulvay avatar ChrisMulvay commented on August 16, 2024

Hi rkusa

I will give this ago over the next day or two and let you know if there are any issues. Sorry for getting back to you so late.

Regards

from pdfjs.

ChrisMulvay avatar ChrisMulvay commented on August 16, 2024

Hi rkusa

I have tried embedding a simple PDF file and this has not worked. Can I direct mail you with the PDF somehow as it is not something I would like on the issues page.

from pdfjs.

rkusa avatar rkusa commented on August 16, 2024

Sure: address removed
Thanks

from pdfjs.

ChrisMulvay avatar ChrisMulvay commented on August 16, 2024

Just another question with relation to the now available feature to embed PDFs. Is it now possible to embed a PDF as a background like you would an Image?

from pdfjs.

rkusa avatar rkusa commented on August 16, 2024

Yes, e.g., as a background for every page:

var header = doc.header()

header.image(img, {
          wrap: false,
          x: 0, y: 0,
          width: img.info.width,
          height: img.info.height
        })

Maybe, I'll add a simpler API in the future.

from pdfjs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.