KingIsulgard / share-extras

Automatically exported from code.google.com/p/share-extras
0 stars 0 forks source link

Media Viewers - Some pdf documents does not show at all with mode="block" in settings #112

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Import attached document in documentlibrary.
2. Go to document-details

What is the expected output? What do you see instead?
I see an empty document (content is all white), even if I maximize and then 
minimize.

What version of the add-on are you using? Please provide version of the
downloaded package, or Subversion revision number.

media-viewers-2.0.jar

What version of Alfresco are you using? On what application server?

4.0.2 Enterprise on Tomcat 6.0.35

What web browser are you using? Please supply browser name and version.

Firefox 16.0.2

Please provide any additional information below.

This happens when if have these settings in web-preview.get.config.xml :

<condition mimeType="application/pdf">
  <plugin defaultScale="page-width" mode="block">PdfJs</plugin>
  <plugin>Embed</plugin>
</condition>

<condition thumbnail="pdf">
  <plugin src="pdf" defaultScale="page-width" mode="block">PdfJs</plugin>
  <plugin src="pdf">Embed</plugin>
</condition>

This pdf loads fine if I have

<condition mimeType="application/pdf">
  <plugin defaultScale="page-width" mode="iframe">PdfJs</plugin>
  <plugin>Embed</plugin>
</condition>

<condition thumbnail="pdf">
  <plugin src="pdf" defaultScale="page-width" mode="iframe">PdfJs</plugin>
  <plugin src="pdf">Embed</plugin>
</condition>

I never saw this issue with an Office document (.docx, .pptx, etc.).
I noticed that this issue happens every time I have a .pdf file with no 
thumbnail in documentlibrary.
Those documents shows fine with default viewer (flash).

Original issue reported on code.google.com by philippe...@gmail.com on 30 Nov 2012 at 2:23

Attachments:

GoogleCodeExporter commented 8 years ago
Document works fine on the pdf.js viewer 
(http://mozilla.github.com/pdf.js/web/viewer.html) in FF and Chrome. But not in 
the PdfJs viewer in r1348.

Do you have any other examples that fail to render?

Original comment by will.abson on 4 Dec 2012 at 5:03

GoogleCodeExporter commented 8 years ago
Peter, any ideas? I wonder if updating to the latest pdf.js libs may fix this.

Original comment by will.abson on 4 Dec 2012 at 5:04

GoogleCodeExporter commented 8 years ago
I have narrowed it down to row 1565 in PdfJs.js
ctx.translate(-view[0] * this.parent.currentScale, -view[1] * 
this.parent.currentScale);

The value of view[1] is way of, compared to other pdf:s this value is usually 0.
If I set a breakpoint on that row and manually set the view[1]=0 it renders as 
expected.

I have however not been able to track down where that faulty value originates 
from. It is not from pdf.js, I have updated that to the latest version from 
github. So somewhere in our width calculations perhaps.
The view array is returned by PDFPageProxy in pdf.js, and that pageInfo.view 
object row 1483 has values originating from our code? Since the same code works 
on the github hosted viewer.

Original comment by loftux.p...@gmail.com on 4 Dec 2012 at 8:53

GoogleCodeExporter commented 8 years ago
I have now a workaround that the reporter can test if building from source, 
change the line (it is not committed you would have to change yourself)-
//ctx.translate(-view[0] * this.parent.currentScale, -view[1] * 
his.parent.currentScale);
-> change to
         ctx.translate(0, 0);

Will, I have tested the above (not committed anything) on many different pdf:s 
and it seems to work for all of them. I also added
         Alfresco.logger.debug("CTX view " + view[0] + ' ' +view[1]);
to see what the standard value of view is, and in almost all cases it is 0. For 
those pdf:s that it is not, it still renders as expected with the above change.
I did not commit this as it is just hiding the underlying issue.

I also noted that the preset zoom width calculations is wrong for this 
particular pdf, that is probably also due to this pdf having the wrong width 
settings.

Original comment by loftux.p...@gmail.com on 5 Dec 2012 at 4:55

GoogleCodeExporter commented 8 years ago
I made the change on PdfJs.js and PdfJs-min.js from media-viewers-2.0.jar and 
it works fine ! Thanks

I also tried to do this modification on latest release from svn/trunk, but I 
can't open any document anymore with that release.
I imported project into Eclipse, made the change on PdfJs.js and lanched 
dist-jar Ant script.
Did I miss something ?

I attached my non working jar.

May I benefit of this issue to ask if, when I open a .pdf document, if the 
document that is showned is the original one or a new pdf which has been 
generated such as it is with .docx, pptx etc. ?

Original comment by philippe...@gmail.com on 5 Dec 2012 at 10:35

Attachments:

GoogleCodeExporter commented 8 years ago
Phillipe, please can you open a separate issue if you are still having 
problems. Please check that you have followed the build instructions in the 
README/wiki, and check for any errors in your server logs or web browser JS 
console.

Original comment by will.abson on 10 Dec 2012 at 1:41

GoogleCodeExporter commented 8 years ago
Peter, I agree with your analysis. I could also not find a call to the 
translate() method in pdf.js viewer.js, so I commented out the line in our 
code. I found this caused the Purchase Order PDF to render fine and it did not 
affect the others that I tested with.

I propose committing that simpler fix (comment out the line and add a note) 
without the debug logging, if you are OK with me doing that?

Original comment by will.abson on 10 Dec 2012 at 1:46

GoogleCodeExporter commented 8 years ago
OK with that.
You may also need to implement a workaround for fixed zoom sizes. If you try 
for example two page fit with this pdf you will see that the extreme value 
reported by view array cause the size to be miniatures.

Original comment by loftux.p...@gmail.com on 10 Dec 2012 at 2:32

GoogleCodeExporter commented 8 years ago
This issue was closed by revision r1358.

Original comment by will.abson on 10 Dec 2012 at 3:53

GoogleCodeExporter commented 8 years ago
Created issue 117 to track the auto-zoom issue seen on the same test document.

Original comment by will.abson on 10 Dec 2012 at 6:34