Background color with GetBrush

Discuss PDF file handling with the Polybios plugin here
Post Reply
User avatar
jPV
Posts: 425
Joined: Sat Mar 26, 2016 10:44 am
Location: RNO
Contact:

Background color with GetBrush

Post by jPV »

According the pdf.GetBrush documentation, if you don't set the page background transparent, it should be white. This doesn't seem to be the case with all PDFs.. with some files you get black background and then texts aren't readable etc (black on black).

Setting bg to transparent seems to work and you can draw the brush over another white brush or something like that, but this work-around slows down things especially on lower spec machines.

So, is there any other work-around, should something be fixed, why is this happening? Can I detect when Polybios fails to show white bg somehow, so that work-arounds could be made only when needed?

Here's an example code... download these example PDF files for it: file 1 and file 1

Code: Select all

@DISPLAY {Width=612, Height=792, Color=#RED}
@REQUIRE "polybios"
f = {
    "PhotoFolioV2.3_Manual.pdf",
    "TVPUserGuide.pdf"
}
For Local i=0 To 1
    pdf.OpenDocument(1, f[i])
    For Local j=0 To 1
        pdf.GetBrush(1, 1, 1, j)
        Cls
        DisplayBrush(1, #CENTER, #CENTER)
        If j Then TextOut(30, 0, "Transparent bg works.") Else TextOut(30, 0, "Background should be white, not black!")
        WaitLeftMouse()
        FreeBrush(1)
    Next
    pdf.CloseDocument(1)
Next

User avatar
airsoftsoftwair
Posts: 4787
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Background color with GetBrush

Post by airsoftsoftwair »

Code: Select all

- Fix: pdf.GetBrush() didn't add a white background for PDFs that didn't have a proper media box setting

Post Reply