Question

Writing transparent layers in PDF

  • 25 April 2016
  • 6 replies
  • 5 views

Badge

Hi,

I read several WMS layers (from the same source) and each layer is written to a single layer in a pdf. For example, I read a WMS background map and write it as one layer, then I read a WMS line network and write it as one layer and this is where I have problems. In my line network layer, I want everything to be transparent, except of course the network itself. Can I create pdf with layers that are transparent for some values (white, no data...) by using a WMS source ? If not, is this a limitation of FME pdf writer or the pdf format itself ?

I can't use the workaround by "pre-generating" the layers before writing them since the pdf would be huge.

By the way, I am using FME 2013...

Many thanks

Rickard


6 replies

Badge

I think you should do this with PDFStyler. There you can set opacity for lines and fillings.

Badge

I'm using a WMS source and saving the result as png (I'm dowloading several images). I read the images (RasterReader) and do some offsetting and scaling. Since they are images I can't set opacity seperately for my lines and the background using PDFStyler. It makes the whole image transparent. I was hoping to be able to set the white background in the raster image transparent (png format) and then write that as a layer in a PDF (conserving the opacity). Any ideas?

Badge

Perhaps this could help you

https://knowledge.safe.com/articles/18764/setting-...

Userlevel 4
Badge +25

There's an exercise in our FME Desktop basic training that I think will help. Check out step 10.

Basically you need to add a RasterExpressionEvaluator transformer. The expressions are:

red8: A[0]
green8: A[1]
blue8: A[2]
alpha8: if (A[2]==255,0,255)

That means that the red, green, blue aspects don't change. But, if the blue aspect is 255 then assume it is white and assign an alpha value to make it transparent.

Technically you ought to test for A[0]==255 AND A[1]==255 AND A[2]==255 to be sure it is white. I am using a shortcut in the training for simplicity's sake. 

And, of course, if you don't have an Alpha band you'll need to add one (RasterBandAdder)

Badge

Thank you for your ideas, however I can't make this to work writing to a pdf...

In UniveraslViewer the layers show correctly, where the colour white in layer commune is transparent and layer raster in shown underneath it (background map). When I write to pdf each layer has to be a single layer in the pdf that I can turn on/turn off. The layer commune will unfortunately have a white background...

Badge +2

Did you ever make it work? I tried numerous workarounds and I can't make it appear transparent on the final PDF.

Reply