Layered PDF´s

The Amyuni PDF Converter is our Printer Driver that enables you to convert any documents to PDF format. If you have any questions about installing and using the Amyuni PDF Converter please post them here.
Post Reply
Untoter
Posts: 22
Joined: Tue Nov 04 2014

Layered PDF´s

Post by Untoter » Tue Nov 04 2014

Hey,

is it possible to have

different Pages like "Page 1" "Page 2" "Page 3"

with different layers for each site?

Page 1
- Layer A
- Layer B
- Layer C

and Page 2

- Layer D
- Layer E
- Layer F

i only found that all Layers must be specified before StartPage(), so you must know the layers before the pages are drawn. So all Layers will be visible to all pages?

Devteam
Posts: 115
Joined: Fri Oct 14 2005
Location: Montreal
Contact:

Re: Layered PDF´s

Post by Devteam » Tue Nov 04 2014

Each page can have its own layers, but the layers pane in Acrobat Reader will still show all available layers to all pages.

You don't need to define the layers at the beginning of the document, you can define them after the last page, e.g.:
SetLayer( hDC, L"" ); // just to inform the printer that we will be using layers
StartDoc
StartPage // page 1
SetLayer( hDC, L"Layer A" );
// draw something on Layer A
...
SetLayer( hDC, L"" );

SetLayer( hDC, L"Layer B" );
// draw something on Layer B
...
SetLayer( hDC, L"" );

EndPage

StartPage // page 2
SetLayer( hDC, L"Layer D" );
// draw something on Layer D
...
SetLayer( hDC, L"" );

SetLayer( hDC, L"Layer E" );
// draw something on Layer E
...
SetLayer( hDC, L"" );

EndPage

// define the layer structure
SetLayer( hDC, L"[(Page 1)[(Layer A)(Layer B)](Page 2)[(Layer D)(Layer E)]]" );

EndDoc

Hope this helps ?

Robert
Amyuni Development Team

Efficient and accurate conversion to PDF, XPS, PDF/A and more. Free trials at - http://www.amyuni.com

Untoter
Posts: 22
Joined: Tue Nov 04 2014

Re: Layered PDF´s

Post by Untoter » Wed Nov 05 2014

did you forget a /Order?

// define the layer structure
SetLayer( hDC, L"[(Page 1)[(Layer A)(Layer B)](Page 2)[(Layer D)(Layer E)]]" );


// define the layer structure
SetLayer( hDC, L"/Order[(Page 1)[(Layer A)(Layer B)](Page 2)[(Layer D)(Layer E)]]" );


wenn i send this

/Order[(Blatt)[(Ebene1)(Ebene2)(S1)(S2)(Text)(Farbtest)(Farbflächen)(Bemaßung)(German Umlautsäüö)]]
i get a broken PDF :(


edit:
forgot the SetLayer( hdc, L"" ); for init pdfa 1.5

Devteam
Posts: 115
Joined: Fri Oct 14 2005
Location: Montreal
Contact:

Re: Layered PDF´s

Post by Devteam » Wed Nov 05 2014

You're right, I forgot the /Order keyword.

I tried your sample thinking the German letters might be an issue but these worked fine. One thing you have to be aware of is that you have to respect the order of Layers. If you have:
Layer 1
Sub-Layer A
Sub-Layer B

Layer 2

You have to output in the page content:
SetLayer( hDC, L"Layer 1" );
SetLayer( hDC, L"Sub-Layer A" );
Draw something ...
SetLayer ( hDC, L"" ); // close Sub-Layer A
SetLayer( hDC, L"Sub-Layer B" );
Draw something ...
SetLayer ( hDC, L"" ); // close Sub-Layer B
SetLayer ( hDC, L"" ); // close Layer 1

And the layer titles should match exactly what you have in the /Order string:
SetLayer( hDC, L"/Order[(Layer 1)[(Sub-Layer A)(Sub-Layer B)](Layer 2)]" );

If this doesn't work for you, you can submit your sample to support@amyuni.com so that we can have a look at what might be wrong in the code.
Amyuni Development Team

Efficient and accurate conversion to PDF, XPS, PDF/A and more. Free trials at - http://www.amyuni.com

Untoter
Posts: 22
Joined: Tue Nov 04 2014

Re: Layered PDF´s

Post by Untoter » Wed Nov 05 2014

everything is fine. i created a huge PDF File with 200 pages and a few more Layers. :))

Great Library!

Post Reply