Comments (17)
Will definitely add a test for this.
I am currently refactoring the imgReplacer class to see where the problem lies.
Here are some things I found about this problem:
- it doesn't seem to behave the same way in the browser (it is not broken on FF)
- a sneaky workaround is to save the images you don't want to be recognized as qrCodes in jpeg format (non PNG)
from docxtemplater.
hey,
just to tell you I think I wouldn't have the time to deal with it until next week, have a lot of contract work to do right now.
from docxtemplater.
Hi,
the error seems to be solved now (since v0.5.4). Please tell me if the error still occurs.
from docxtemplater.
Hi,
With node this correction doesn't work. When docxtemplater tries to find a qrcode into an image without qrcode, it fails with this message:
findpat.js:398
throw "Couldn't find enough finder patterns:"+startSize+" patterns found";
from docxtemplater.
Hi,
I have never seen this issue before. Can you please upload an example that
does this ?
Does this work in the browser but not in node, right ?
Also, are you up to date with the latest version ?
On 6 May 2014 16:46, "zamentur" [email protected] wrote:
Hi,
With node this correction doesn't work. When docxtemplater tries to find a
qrcode into an image without qrcode, it fails with this message:
findpat.js:398
throw "Couldn't find enough finder patterns:"+startSize+" patterns found";—
Reply to this email directly or view it on GitHubhttps://github.com//issues/24#issuecomment-42311597
.
from docxtemplater.
I am up to date with the version 0.5.4 fdaa90e
I did not try in browser, but I tried with and without my png image. This png image doesn't contain any qrcode. With: it fails, without it works.
I have fix this problem with this code at line 58 in imgReplacer.coffee:
finished= (a) =>
png.decoded= a
try
@qr[u]= new DocxQrCode(png,@xmlTemplater,imgName,@xmlTemplater.DocxGen.qrCodeNumCallBack)
@qr[u].decode(@imageSetter)
catch e
mockedQrCode={xmlTemplater:@xmlTemplater,imgName:imgName,data:oldFile.asBinary()}
@imageSetter(mockedQrCode)
from docxtemplater.
I have checked @zamentur's problem and successfully repeated it on my system.
Also I've replicated slightly different problem: qrCode + tagging are true and document contains both qr and non-qr png, which makes templater fail. I suggest to add this to test cases.
@zamentur's quick-fix works correctly and doesn't ruin any tests. Probably it's good idea to add it to the codebase (at least temporarily to get some time to think about better solution).
By the way, I am talking about node.js environment.
from docxtemplater.
@LitRidl I can't download your files on firefox nor chrome, can you upload them somewhere else ?
Update: Download all button did work !
from docxtemplater.
The fix of @zamentur doesn't solve the regression test I have just added to branch #24.1. I think those are two separate issues.
They is actually no error that is thrown by docxtemplater in the regression text. However, the generated file is 0 Byte, that's why the image doesn't show
from docxtemplater.
@edi9999, I see.
For my own code I use his pseudo-fix because for me it is far more important to have both qr and non-qr images in one file. Are there any better solutions rather than this try-Ok,insert-catch-Ok,preserve
fix?
from docxtemplater.
Hi, I have added a fix for this, However I have not tested if it works because I have never encountered the issue my self. Basically I'm also doing a try catch but more close to the call of the qrcode library.
It's in the decode function of the DocxQrCode.coffee file:
try
if env=='browser'
@qr.decode("data:image/png;base64,#{@base64Data}")
else
@qr.decode(@data,@data.decoded)
catch
@qr.result=null
@qr.callback()
I think it should then do nothing with images where the qrcode library doesn't find enough patterns.
I haven't created a new version on npm too.
from docxtemplater.
Well, somehow it failed for me.
I think I have to give you kind of test for this situation: here I have file with both qr and non-qr image, config.json for it, expected output and real output.
outputReal.docx
is obviously corrupt: non-qr images are just killed in it, but at least the file is opened.
outputExpected.docx
is correct: it preserved both qr and non-qr images. I've got it by using zamentur's fix.
Actually there are two modes for pictures in document right now: all images either must be qr, or all of them must be non-qr. So, I think this case should be added to templater's test suite.
from docxtemplater.
By the way, in your fix you actually just ignore original image in case if it was qr-scanned?
It doesn't preserve original non-qr image, I've just tested.
The only thing that changed is that I see 'output' in console twice now, which is sign, that it executed callback. And that is all. Also, qr-callback is called only in catch
. Is that Ok?
from docxtemplater.
Actually the @callback method should be called whether an exception is thrown or not. When no exception is thrown, it's the qrcodejs library that will wall the callback method: https://github.com/edi9999/docxtemplater/blob/master/vendor/jsqrcode/qrcode.js
from docxtemplater.
The branch I'm working in is bug-#24.2
from docxtemplater.
If you only use the command line interface, you could try to install this version: b8110b0
However, the bug is not still yet completely repaired because for now, the document is outputed two times (which is not the expected behavior)
from docxtemplater.
Fixed for good ! :-)
from docxtemplater.
Related Issues (20)
- The parser parses '()' incorrectly in case of using custom delimiters like this '$(', ')' HOT 6
- dropUnsupportedFileTypesModules called twice by constructor HOT 3
- Cannot resolve @Name placeholder HOT 2
- Chart Module: Unexpected Behavior with Null Value in Data HOT 3
- Differentiate between conditions and loops when getting tags HOT 1
- Conditional assignment doesn't work as expected HOT 1
- Page break propogates to all elements inside div HOT 5
- Numbering for conditional text HOT 3
- Question: Importing ExpressionParser in TypeScript. HOT 6
- When I write a tag in complex content, it doesn't work HOT 4
- HTMLModule Dependencies causing errors HOT 1
- paragraphLoop doesn't seem to work HOT 2
- ChartModule + ErrorLocationModule HOT 2
- Bun.sh HOT 1
- Trying to setup angular parser, but is failing with compilation error. HOT 8
- getSize 返回一个promsie ,word预览正常,但是导出word图片丢失 HOT 2
- Compile (tsx) issue with TxtTemplater HOT 1
- Ability to Insert IDs into XML Tags HOT 1
- Slides demo is broken HOT 1
- According to Microsoft Word, the generated file is corrupted. Cannot open it. HOT 12
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 docxtemplater.