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?
Layered PDF´s
Re: Layered PDF´s
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
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 - https://www.amyuni.com
Efficient and accurate conversion to PDF, XPS, PDF/A and more. Free trials at - https://www.amyuni.com
Re: Layered PDF´s
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
// 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
Re: Layered PDF´s
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.
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 - https://www.amyuni.com
Efficient and accurate conversion to PDF, XPS, PDF/A and more. Free trials at - https://www.amyuni.com
Re: Layered PDF´s
everything is fine. i created a huge PDF File with 200 pages and a few more Layers. )
Great Library!
Great Library!