PDF Sprite problem

The following code tries to display a full-page PDF of text. IT either shows nothing or one or two words.

Am I overusing the sprite pdf capability? is there a max size for the pdf?

Thanks

displayMode(FULLSCREEN)
    
function setup()     
    
    spriteMode(CORNER)
    page1l = image(400,600)    
    setContext(page1l)  
    sprite("Dropbox:Tikkun-01 3",0,0)  
end


function draw()     
    
 sprite(page1l,0,0)
    
end

Try resetting your context by adding the line:



setContext()



Add this after you draw your sprite in page1l in setup()

Thanks @Slashin8r – tried it, but no difference. One text pdf only shows 3 words, a second text pdf shows nothing.

@Simeon – how robust is the PDF code in Codea? The PDFs in question come from InDesign, with about 20 different fonts in the file.

If it is due to the size of the PDF, you can try making a test PDF that is much smaller and uses only a few fonts. Let me know the results, I’m definitely curious to see how you get it to work. In the meantime I will continue to test this as well.

I advise convert pdf to png

Yeah it really seems like converting to an image such as png or jpg is the way to go.

function setup()
    pdfImage = nil
    http.request("http://www.sciweavers.org/download/registration_form_1372951272.png", success)
end

function success(data, status, headers)
    pdfImage = data
end

function draw()
    background(20,20,40)
    if pdfImage ~= nil then
        sprite(pdfImage, WIDTH/2,HEIGHT/2)
    end
end

Original pdf file: http://northernicefastpitch.com/tournaments/9u/05252013_USSSA/registration_form.pdf


Converted to png using an online pdf to image converter

I’d reached the same conclusion – I wanted to use the PDF because 1) we update the PDF from time to time, and I’d rather not have the extra step of making a jpg 2) I’d like to find some lua code to read the content of the pdf – something not possible with jpgs.

Some PDFs work, some don’t. The one’s that don’t have one dimension greater than 1000

I seem to recall some discussion of sprite size limit – @Simeon, does that apply to PDF size as well? Even when scaled down? (I.E. the sprite is 400x600, the PDF is 792x1224)

What would happen if you tossed the PDF into a mesh and drew it that way instead?

@akiva, anyway you could share one or two of the PDFs you are using? I would love to see if I can recreate the issue you are experiencing.

@Slashin8r - sprites are drawn using meshes anyway, no probably no difference

Ah, so it really does seem like saving as an image is the only way to go as of now. Trying to find a good website that can convert PDF to image on the fly by use of a single URL. Then you could call an http.request for each PDF and have an image returned to be drawn.

@Slashin8r try https://www.dropbox.com/s/jzlz3es0b78hn6p/Tikkun-01%204.pdf

I’m using an iPad 1 - i dont know if that’s an issue…

Since pdfs are size independent I’m wondering why/how codea’s dropbox chooser determines the “size” of the image. From the internal thumbnail jpg? @Simeon?

When loading a PDF you can pass a second parameter to readImage to specify the width.

I’ve had no problem with loading PDFs.

@Andrew_Stacey im using sprite to load the pdf - i tried adding width and height - still nothing

It’s an issue with the new sprite batching code, I think.

displayMode(FULLSCREEN)
    
function setup()     
    img = readImage("Dropbox:Tikkun-01 4")
    spriteMode(CORNER)
    spriteBatching(false)
    page1l = image(400,600)    

    setContext(page1l)  
    background(29, 62, 59, 255)
    sprite(img,0,0,400)
    setContext()
end


function draw()     
    background(77, 77, 77, 255)
     sprite(img,0,0)

    sprite(page1l,0,0)

end

Try commenting out the spriteBatching = false line.

Alerting @Simeon

Same if loading via sprite:

displayMode(FULLSCREEN)
    
function setup()     
    img = readImage("Dropbox:Tikkun-01 4")
    spriteMode(CORNER)
    spriteBatching(false)
    page1l = image(400,600)    

    setContext(page1l)  
    background(29, 62, 59, 255)
    sprite("Dropbox:Tikkun-01 4",0,0,400)
    setContext()
end


function draw()     
    background(77, 77, 77, 255)
     sprite(img,0,0)

    sprite(page1l,0,0)

end

@Andrew_Stacey that works - but the pdf is much darker than the original.
If i comment out the background in draw it doesnt work -