RavishaHesh / PDFJsAnnotations

Wrapper for PDF JS to add annotations
MIT License
333 stars 99 forks source link

File after annotate is bigger (x4) #34

Open vavicheth opened 3 years ago

vavicheth commented 3 years ago

Thank you for your great package. I have a problem with size after annotation. Do you have a solution for optimizing after annotate?

RavishaHesh commented 3 years ago

Try setting this to "Fast" https://github.com/RavishaHesh/PDFJsAnnotations/blob/cb4131d865b981a8599138b7bd89bbf580ea845d/script.js#L9

vavicheth commented 3 years ago

Thanks for your advice. It's nothing change size. When I change the scale to 1 (scale: 1), It's smaller but my pdf file smaller than paper (as padding).

RavishaHesh commented 3 years ago

Scaling is similar to zoom function, but pageImageCompression sets the compression level of images of each page.

vavicheth commented 3 years ago

I tried to change pageImageCompression: "FAST", // FAST, MEDIUM, SLOW(Helps to control the new PDF file size) but It still big size.

hichamhargal commented 3 years ago

Try this solution

kalana85 commented 2 years ago

Now pdf files save as an image. (Image inside pdf file). Can we make save it as normal pdf. (I mean as selectable text format. Not images in pdf).?

RavishaHesh commented 2 years ago

@kalana85 It's possible but requires little bit of time to go through the documentations and stuff. I've started to work on that and haven't had time to work on that for last few months. You can find it in the dev branch. Last time I worked on that I was stuck in something related to the fonts.

bzxgcs commented 2 years ago

@ kalana85这是可能的,但需要一点时间来浏览文档和内容。我已经开始做这件事,但在过去几个月里一直没有时间做这件事。您可以在 dev 分支中找到它。上次我工作时遇到了与字体相关的问题。

If it is difficult, could you save annotation data in a single file? Then we can add annotation to pdf by other backend(such as python).

fewbackseven commented 2 years ago

The issue still persists even after disabling retinascaling in pdfannotate.js The file gets 4 times bigger and the quality is lost. . . Let me know if there are any other solution for this issue? thanks

fewbackseven commented 2 years ago

did anyone find the solution?

fewbackseven commented 2 years ago

Yes.. The solution here worked for me. After disabling the Retinascaling, Assigning Imagecompression to 'FAST', I restricted the page size to A4 while saving the pdf. Please refer below code..

PDFAnnotate.prototype.savePdf = function (fileName) { debugger; var inst = this; //var format = inst.format || 'a4';
var format = 'a4'; //<------------ Restricted the page size to A4 here by addling this line in pdfannotate.js var orientation = inst.orientation || 'portrait'; if (!inst.fabricObjects.length) return; debugger;

var doc = new jspdf.jsPDF({ format, orientation }); if (typeof fileName === 'undefined') { fileName = ${new Date().getTime()}.pdf; PDFAnnotate.prototype.savePdf = function (fileName) { debugger; var inst = this; //var format = inst.format || 'a4';
var format = 'a4'; //<------------ Restricted the page size to A4 here by addling this line in pdfannotate.js var orientation = inst.orientation || 'portrait'; if (!inst.fabricObjects.length) return; debugger;

var doc = new jspdf.jsPDF({ format, orientation }); if (typeof fileName === 'undefined') { fileName = ${new Date().getTime()}.pdf; }