Comments (12)
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.
Thanks for your reply. It would be a great and valued addition as at this time I cannot find a solution.
from pdfjs.
@jsNifty Do you want to add whole sides from an existing PDF file, or embed PDFs like images?
from pdfjs.
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.
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.
This is excellent! I look forward to working with this feature in the near future.
Thanks!!
from pdfjs.
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.
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.
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.
Sure: address removed
Thanks
from pdfjs.
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.
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)
- Error: Using spaces or \t at the beginning of a line when using Chinese will result in no line breaks HOT 1
- ExternalDocument can not create pdf from buffer HOT 1
- TypeError: Cannot read property '12' of undefined HOT 11
- Can I create a large pdf without loading the entire file into memory? HOT 1
- Missing outline when merging PDF files HOT 1
- how can I extract contents from a pdf HOT 1
- Downscale images in external PDF HOT 1
- Cannot catch error in asBuffer() HOT 21
- imported in .vue file but giving issue HOT 1
- Combined PDF size is bigger than the originals HOT 2
- Fragments are appearing in wrong order... HOT 1
- Invalid throw code in text._render HOT 1
- Issue with Inaccurate Text Highlighting in PDF Search Using ng2-pdfjs-viewer - Version 13 HOT 1
- The add() method of the table cell text method does not respect the "textAlign" or "alignment" properties HOT 1
- How do I set the font My characters are now garbled ? HOT 1
- Improve client-side support HOT 1
- Failed to add document containing lexer HOT 1
- Crash when processing PDF using nodejs HOT 2
- Underline does not seem to work well
- I get Process error while using this library in react js
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pdfjs.