Comments (11)
pdf.loadFromJSON(serializedJSON) // continue edit with saved JSON. To do this on page load use ready
option(scripts.js line 5)
var pdf = new PDFAnnotate("pdf-container", "pdf.pdf", {
onPageUpdated(page, oldData, newData) {
console.log(page, oldData, newData);
},
ready() {
console.log("Plugin initialized successfully");
pdf.loadFromJSON({
page_setup: {...},
pages: [...]
});
},
scale: 1.5,
pageImageCompression: "MEDIUM", // FAST, MEDIUM, SLOW(Helps to control the new PDF file size)
});
hope this answers your question
from pdfjsannotations.
Thank you. I noticed the JSON file has a background. What I thought JSON file has complete things to draw something in the canvas including pages..background etc. So why do we need to use PDF files (new PDFAnnotate("pdf-container", "pdf.pdf")?
I assume we have two options either load everything from JSON file or load from PDF. As per this example, we are loading PDF and JSON files. Will it not create a duplicate background? If so if we convert it into pdf the file size could be larger?
In this case, If I am not wrong we could auto detect PDF or JSON ( ie new PDFAnnotate("pdf-container", "pdf.pdf".. or new PDFAnnotate("pdf-container", "pdf.json"..). If JSON we do this and if PDF do this ..
from pdfjsannotations.
Good catch! I didn't think about that before. I think it's better to load the PDF and render annotations on top of that. I'll push a fix for that ASAP. Thank you very much for bringing this up
from pdfjsannotations.
Thank you for your hard work. For PDF loading, is it possible load objects only without the background from JSON file ? Basically, I am saving JSON data in a database without the background since itβs huge. So load backgrounds from pdf but objects from JSON file.
Thank you again.
from pdfjsannotations.
Yes, that's what I'm planning to do.
from pdfjsannotations.
@davidhagen I've updated master with a fix. Please note that serializePdf
function now requires to pass a callback function as first argument
from pdfjsannotations.
Thank @RavishaHesh.
When we load the JSON file the PDF background disappears we only see objects. I think we should add the PDF background when we loop through the JSON file or make sure when read through the JSON file it ignore the background.
Thank you again .. well deserve
from pdfjsannotations.
Since I have one page PDF ugly way I'm doing this -
when we loop through PDF pages and add background I assign inst.background=background
then when loading from JSON I add the background
fabricObj.loadFromJSON(pages[index], function () {
**fabricObj.setBackgroundImage(inst.background, fabricObj.renderAll.bind(fabricObj));**
inst.fabricObjectsData[index] = fabricObj.toJSON()
})
from pdfjsannotations.
That's strange. I've tested it before pushing to the master branch. Can you check the example in the repo? Please let me know if you can replicate the same behavior on that as well. Thanks
BTW I did saw that behavior on as soon as I've updated the code but after hard reload I wasn't able to re-produce that
from pdfjsannotations.
@RavishaHesh, is it possible to improve the image quality and text that pdf.js generate? Basically, the canvas/image is not clear as the original PDF.
from pdfjsannotations.
same issue facing background gone. @RavishaHesh @ghost
from pdfjsannotations.
Related Issues (20)
- Enable annotation layer (text and link)
- 2 Pages View like a book
- load or save pdf slow HOT 1
- Saved PDF text is blurry HOT 1
- loadFromJSON loses backgroundImage HOT 1
- Memory canvas use exceeds the maximum limit (254mb) HOT 1
- loading image from sample_output breaks background HOT 3
- Arrow | Pencil Tool Glitch HOT 1
- Can't Save PDF HOT 1
- get the coordinates of x,y ?
- TEXT LAYER HOT 3
- add zoom in / zoom out buttons
- Add predefinited image to canvas
- return saved image as base64
- Password protected pdf with password how to open Please Tell Me.
- Getting Blur PDF after saving Annotation HOT 1
- on a tablet I scroll to the canvas and can't scroll below? HOT 2
- PDF file does not open HOT 7
- Place image on the currently viewed page
- Edting PDF?
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 pdfjsannotations.