Using current version of three.js - Win 7 64bit - nvidia high end card, chrome 42, gets the error
cannot read property x of undefined
looks like wb is null in the minified code
main.html, obj and texture file can be obtained here:
http://96.56.225.196:8090/
Related
I am generating the PDF using iTextPdf version 5 and am using Calibri font inside that PDF. I have loaded that font from the src/resource/fonts folder as I am working with Boot. All is working fine as I can view that PDF in my project and download also except that when I am trying to open the PDF using Adobe Reader, than the page is showing something like that-
I have opened that PDF using Google Chrome, WPS office and other PDF Reader and that PDF is working perfectly fine but I can't seem to understand what is wrong when I am trying to view the PDF using Adobe. I have also attached the screenshot of PDF in WPS office below -
Here is the code that I have loaded the font in my PDF -
static URL calibriFont = UserProfileController.class.getResource("/static/fonts/Calibri Regular.ttf");
static Font namefont = FontFactory.getFont(calibriFont.toString(), 20, Font.BOLD, new BaseColor(139, 0, 0));
FontFactory.register(calibriFont.toString());
Here is the PDF File link shared below -
Sample PDF
In short
Additional data was added to the PDF after initial generation, introducing a cross reference error. Take the first 1019493 bytes of the file to get the original working file.
My first guess would be another program postprocessing the PDF incorrectly but as it turned out the iText objects were closed incorrectly resulting in that error.
In detail
The final version of the PDF you shared is not generated by iText, at least not by correct iText usage.
The file has a size of 1021972 bytes. The initial 1019493 bytes constitute a valid PDF.
The extra 2479 bytes extend the PDF providing some updated old object, some new objects, and a full cross reference table. And in this cross reference table the offset entry for the first new object 33 is incorrect, it should be 0001019493 (the first byte added after the original contents, i.e. the start of the first new object) but it is 0001018667 (the start of the cross reference table of the original PDF).
Thus, a PDF processor will incorrectly find the original cross references when looking for the new object 33.
As the object 33 happens to contain the FontDescriptor of the font Calibri in the updated object 1, an attempt to parse this font fails. This font is referenced from all document pages.
As a results, Adobe Reader stops drawing each page as soon as it comes across an instruction using that font.
Some other PDF viewers repair that error under the hood and, therefore, show you what you want to see.
The actual cause
In a comment you write
The error was coming due to PdfWriter instance object was closed before document.
Indeed, you are not expected to close the PdfWriter at all, and in particular not before the Document.
When requesting a PdfWriter using PdfWriter.getInstance for a Document, a PdfDocument instance is created and registered as listener of the Document; then a PdfWriter is created and registered as listener of the PdfDocument.
To finalize the PDF generation you are expected to close the Document. This will call its listeners' respective close methods, i.e. PdfDocument.close, which will finish some last objects, write them, and then call its own listener's close method, i.e. PdfWriter.close, which will write the cross references.
In your code you first explicitly called PdfWriter.close (which wrote the first cross reference table) and then Document.close (which caused PdfDocument to write some objects and then trigger PdfWriter.close again to write the second cross references). This incorrect sequence also resulted in an incorrect cross reference offset.
I have found the solution of my problem as what I was doing that, I have closed PdfWriter instance before the document. When I closed that instance after the document, it was working fine.
Today I encountered one weird bug in Chrome's printing behavior.
When I try to print a dynamically created PDF using Chrome (also in Firefox), every image inside the PDF gets a little bit smaller (8mm).
This doesn't happen neither in Adobe Reader/Acrobat/MacOSX Default Printer Dialog.
Let me explain more about my code so far:
dynamic PDF:
I use prawn to dynamically create a PDF A4 (landscape format) using this code:
require 'prawn'
require "prawn/measurement_extensions"
class CustomPdf < Prawn::Document
def initialize(label) # A4
super({
:page_size => "A4",
:page_layout => :landscape,
:margin => 0,
:print_scaling => :none})
image "my_image.png", :width => 213.mm, :at => [3.mm, 3.mm]
end
end
nested image inside the PDF:
The Image nested inside the PDF has a size of 213mm x 70mm with
300 DPI. In Pixel: 2515x827.
I create the Image using RMagick but the size, dpi and everything so far seems to be alright. So no further explanation at the moment.
Expected result:
The printed PDF will show an image with 213cm width.
Actual result:
The printed PDF will show an image with 205mm width.
What I tried so far
Setting the prawn page_size to something lower than A4 (since the Image isn't bigger as A4 as well...).
Playing around with print_scaling(there are 3 modes, :none, :AppDefault, :something_except_the_other_ones (Read more about it here)
Giving the image a fixed height (70mm)
Playing around with various settings provided by the Chrome Printer Dialog
Tested under Windows Chrome (it's 213mm there, weird), maybe it's related to MacOSX Chrome?
Tested under IE11 (205mm) unfortunately.
Neither of these did anything.
I looked through the Bugreporters of Chromium and found 2 people who might share the same problem as I do:
https://code.google.com/p/chromium/issues/detail?id=97972
https://code.google.com/p/chromium/issues/detail?id=67091
The last one was touched 2013 but no one said anything that actually worked for my case.
Examples
Here is an example 300 DPI image which width is 2515 px:
If Imgur changes the resolution to 72, you can pull the example image from the repository (link: https://github.com/posixpascal/chrome-printing-bug/blob/master/example.png)
Here is an example PDF
Direct Link: Direct Link
GitHub PDF Viewer: https://github.com/posixpascal/chrome-printing-bug/blob/master/output.pdf
Github Repository with example image & pdf generator script
https://github.com/posixpascal/chrome-printing-bug
Unfortunately I can't change the width of the image (not even a pixel).
Someone experienced the same problem?
Any ideas? It's an interesting puzzle I guess... :x
When I print a plain image or a website with Chrome there is a 'Use Original Size' or '100% size' option which I don't have when printing the PDF.
I also tried making a webpage instead of a PDF and set the image width to 213mm which didn't work either...
This is my test results from what i have seen by using a windows system and a Mac ( Yosemite )
Windows :
Printed the PDF in Chome : Perfect - 213 mm
Printed in IE : Perfect - 213 mm. This was less before ( around 205-210ish ). So changed the default print settings :
Selected the Print option -> Used Print Dialog -> Selected the printer -> Print Preferences -> Advanced -> Paper Size -> Changed scaling manually -> tested A4, A5 and so on.-> A5 ( for some reason gave me 213 )
So i moved onto the Mac.
Mac Findings:
Changed Paper Size and tested the same : Size was 213 mm.
This was done like this : Apple Print
So naturally, i tested printing it through Chrome directly instead of opening the PDF through OSX -> Printed at 205 mm.
Tested with printscaling on prawn at :appdefault -> Printed at 213 mm.
Tested the same on Firefox -> lower than 205 - 210 mm.
So i dont really know if its a Chrome issue because its acting weird on Firefox for me.
So ultimately, these are my findings after testing out the code on my end.
I experienced a similar 8 mm shrinkage using Chrome on Windows. Checked all my printer properties and settings and couldn't find what could be doing it. Turns out, I had the option "fit to page" ticked in the Chrome printing (ctrl+p) screen. Un-ticked it and reprinted a page, compared their widths and they were 8 mm off. Sometimes it's the simple things...
In my experience, Chrome prints html usually smaller. It may have to do with WebKit engine having "smart shrinking" feature. I have come across to it here (text search shrinkage). Or, it might be just that, Chrome developers gave it a little tweak since people in the past complained that the stuff does not fit the print.
I'm trying to import the simpliest Blender scene (camera included) into three.js, but whatever set of options I mark when exporting I always get an exception (data is undefined) when doing the "loader.parse" of the file content (a json string or event an already parsed object) and nothing is shown.
What can be wrong? Is it a bug?
Im using the latest threejs version from github and blender 2.72.
This is what the console.log of the JSON parsed file looks like:
Object { urlBaseType: "relativeToScene", metadata: Object, objects: Object, geometries: Object, materials: Object, embeds: Object, transform: Object, defaults: Object }
Thanks!
I have inspected the code step by step and it seems that the Blender plugin is outdated, the expected data structure at many points for the current version of three.js loaders is quite different then tue data structure returned by the plugin.
EDIT: It's already working in the dev branch! :D
enter link description here
I am trying to use sparks.js in my app via the THREEx.Sparks module that Jerome made for his live sparks editor. However it only works with three.js up to and including r50 - after which the sparks trail never gets rendered.
I have put up a (somewhat) minimal fork of the editor for all to play with. The cylinder always gets drawn, but as we step up through the three.js revisions:
r46 works, but is of course now very outdated
r50 and r49 draw the particles as expected, but with this WebGL error: WebGL: INVALID_ENUM: activeTexture: texture unit out of range
starting at r51, the particle system of the sparks is not drawn
The error is quite likely to do with how THREE handles improperly initialised textures. I have chased it down to the 128x128 radial texture created in _buildDefaultTexture inside THREEx.Sparks.js.
The reason this is a SO question (and not a GH bug report) is that THREE r51+ have evidently got the right error handling - they don't even attempt the bad behaviour because that makes WebGL a sad panda, whereas r50 and down just did it anyway and caused errors. My question is:
what exactly is THREEx.Sparks.js not doing properly here
and why did it kinda still work prior to r51
System info: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.57 Safari/537.17 | WebGL 1.0 (OpenGL ES 2.0 Chromium) | WebKit | WebKit WebGL | WebGL GLSL ES 1.0 (OpenGL ES GLSL ES 1.0 Chromium)
Screenshot of sparksjs-dev in action using r50 available for your viewing pleasure at i.stack.imgur.com/p5EfN.png (if it hasn't been pulled yet), which shows the bungled uniform1i and activeTexture calls in the WebGL debugger.
I am not able to debug your code for you, but I can definitely point you in the right direction.
First, see the Migration Wiki for help upgrading to the current version.
For example, you will see that in THREEx.Sparks.js,
texture : { type: "t", texture: this._texture }
should now be
texture : { type: "t", value: this._texture }
There may be other issues.
I can't comment on old versions of three.js, only the current one.
three.js r.55
I have a project in Python 2.7 and PyGTK.
I need to create a transparent background window, but still be able to display images (pixmap and mask based) and other objects inside of the window.
I am using the following code, but no image objects are showing up in Ubuntu (Oneric Ocelot), and I'm getting an error, posted below, (though the window otherwise displays, with its button objects). This won't even render in Windows 7 (this error also posted below).
def expose(widget, event):
cr = widget.window.cairo_create()
# Sets the operator to clear which deletes everything below where an object is drawn
cr.set_operator(cairo.OPERATOR_CLEAR)
# Makes the mask fill the entire window
cr.rectangle(0.0, 0.0, *widget.get_size())
# Deletes everything in the window (since the compositing operator is clear and mask fills the entire window
cr.fill()
# Set the compositing operator back to the default
cr.set_operator(cairo.OPERATOR_OVER)
hab_fish_win = gtk.Window()
hab_fish_win.resize(640, 480)
hab_fish_win.set_resizable(False)
hab_fish_win.set_decorated(False)
hab_fish_win.set_has_frame(False)
hab_fish_win.set_position(gtk.WIN_POS_CENTER)
hab_fish_win.set_app_paintable(True)
screen = hab_fish_win.get_screen()
rgba = screen.get_rgba_colormap()
hab_fish_win.set_colormap(rgba)
hab_fish_win.connect('expose-event', expose)
hab_fish_win.show()
WINDOWS 7 RUN:
Traceback (most recent call last): File "C:\Users\user\MousePaw
Games\Word4Word\PYM\fishtest2.py", line 337, in
HAB_FISH() File "C:\Users\user\MousePaw Games\Word4Word\PYM\fishtest2.py", line 100, in init
hab_fish_win.set_colormap(rgba) TypeError: Gtk.Widget.set_colormap() argument 1 must be gtk.gdk.Colormap, not
None
A quick "print rgba" confirms that rgba is "None", thus the error.
UBUNTU "ONERIC OCELOT" RUN:
Gtk Warning: Attempt to draw a drawable with depth 24 to a drawable with depth 32
What is going on? I desperately need that transparent background for the window.
Okay, after hours of research, I have found that Windows does not support this sort of transparency. As for the Linux error, I don't know.
I'm porting to PyGObject, and using another method for my ends. I would suggest readers of this answer look into it.