Image shifted
Hi all! I've already red other issues but i didn't find a solution, this is my problem: i've copied the playground images example and after the PDF creation on the browser everything is ok but if i open the pdf file all the images are shifted to the right...
I've already tried with jpg, png but the result is the same, also switching from Windows 7 to iOS.
How can i fix this?
Greeting
Andrea
No one has the same problem???
I just tested and I have the same problem as you. All the images get shifted to the right when you reopen the pdfs.
I took a quick look at the files and it seems that this line in elementWriter.js is what is causing the problem:
image.x = context.x + (image.x || 0);
I am taking a guess but it seems the value for image.x do not get resetted when you reopen the pdf which causes the problem.
If you are not setting an initial position then changing the above line to:
image.x = context.x;
might help.
This might break your initial positioning, if you set one, for the images so beware. Hopefully one of the devs will take a look into this soon.
Now it works perfectly! Thanks gabucito!
Another solution I've found is to redefine your docDefinition every time you generate the PDF. In other words, structure it like
var savePDF = function(){
var docDefinition = {...};
pdfMake.createPdf(docDefinition);
}
and call savePDF() every time. @Elyahou has a cleaner solution at #376 but I figured this may help someone.
By the way, this issue has been duplicated multiple times: #389, #446, #592
Fix is included in the new version (0.1.22).