View Issue Details

IDProjectCategoryView StatusLast Update
0011500ScribusImport / Exportpublic2016-02-20 08:12
Reporterchristoph_s Assigned Tofschmid  
PrioritynormalSeverityfeatureReproducibilityhave not tried
Status assignedResolutionopen 
Product Version1.5.0svn 
Summary0011500: Enable import of PDF layers
DescriptionScribus does an excellent job at exporting PDF layers, but reconstruction of PDF layers upon opening a PDF file (in contrast to importing it as a vector or image file) isn't available yet (perhaps due to limitations of PoDoFo?).
Tagsupstream
Patch

Activities

jghali

2013-04-19 09:03

administrator   ~0030091

PDF does not have layers as defined in Scribus, Indesign or Photoshop. PDF has what is called in specs "Optional content group". They are available since PDF 1.5. So basically layers are translated to a specific type of groups whose view can be enabled or disabled by users when exporting to PDF 1.5 and enabling specific option. In other cases, the output has lost all notions of layers.

The trick also is that PDF can have "Optional content group" embedded in other "Optional content group" and this is where they are different from layers. That means we can translate our layers to PDF "Optional content groups" but "Optional content groups" can not be necessarily converted back to layers, except the top one... In specific case, even the top one may not be converted to layer.

Fyi PoDoFo is not used when importing PDF, most of the work is done using poppler when available. When not available, the PDF goes the EPS/PS way through Ghostscript in which case any notion of layers is of course lost.

fschmid

2013-04-19 19:25

developer   ~0030094

To a certain extend this works already, but these "Optional content" stuff can be quite tricky. Poppler library has only limited support for this. I had send a patch to improve this, but it was only included in a crippled form with the remark "Do not use the poppler lib directly". Unless these guys do not rethink their usage policy for their library i won't send any more patches to them.

Kunda

2015-12-07 18:43

updater   ~0037855

Franz, I can't find the patch on their bugtracker. Can you direct me to it ?

fschmid

2015-12-07 21:32

developer  

poppler_marked_content.diff (2,310 bytes)   
diff -U 3 -H -d -r -N -x '.*' -- Entwicklung/poppler-0.19.4/poppler/Gfx.cc Downloads/poppler-0.19.4/poppler/Gfx.cc
--- Entwicklung/poppler-0.19.4/poppler/Gfx.cc	2012-04-24 19:10:58.000000000 +0200
+++ Downloads/poppler-0.19.4/poppler/Gfx.cc	2012-04-27 21:21:38.000000000 +0200
@@ -4969,6 +4969,7 @@
       if ( res->lookupMarkedContentNF( name1, &markedContent ) ) {
         bool visible = contentConfig->optContentIsVisible(&markedContent);
         mc->ocSuppressed = !(visible);
+		out->beginMarkedContent(args[0].getName(), &markedContent);
       } else {
 	error(errSyntaxError, getPos(), "DID NOT find {0:s}", name1);
       }
@@ -4993,6 +4994,10 @@
     printf("\n");
     fflush(stdout);
   }
+
+  if(numArgs == 2 && args[1].isDict()) {
+    out->beginMarkedContent(args[0].getName(),args[1].getDict());
+  }
   ocState = !contentIsHidden();
 }
 
@@ -5010,6 +5015,7 @@
 
   if (mcKind == gfxMCActualText)
     out->endActualText(state);
+  out->endMarkedContent(state);
   ocState = !contentIsHidden();
 }
 
diff -U 3 -H -d -r -N -x '.*' -- Entwicklung/poppler-0.19.4/poppler/OutputDev.cc Downloads/poppler-0.19.4/poppler/OutputDev.cc
--- Entwicklung/poppler-0.19.4/poppler/OutputDev.cc	2012-04-25 18:48:12.000000000 +0200
+++ Downloads/poppler-0.19.4/poppler/OutputDev.cc	2012-04-27 21:20:09.000000000 +0200
@@ -157,6 +157,15 @@
   drawImage(state, ref, str, width, height, colorMap, interpolate, NULL, gFalse);
 }
 
+void OutputDev::endMarkedContent(GfxState *state) {
+}
+
+void OutputDev::beginMarkedContent(char *name, Dict *properties) {
+}
+
+void OutputDev::beginMarkedContent(char *name, Object *dictRef ) {
+}
+
 void OutputDev::markPoint(char *name) {
 }
 
diff -U 3 -H -d -r -N -x '.*' -- Entwicklung/poppler-0.19.4/poppler/OutputDev.h Downloads/poppler-0.19.4/poppler/OutputDev.h
--- Entwicklung/poppler-0.19.4/poppler/OutputDev.h	2012-04-25 18:47:59.000000000 +0200
+++ Downloads/poppler-0.19.4/poppler/OutputDev.h	2012-04-27 21:20:21.000000000 +0200
@@ -272,6 +272,9 @@
 
   //----- grouping operators
 
+  virtual void endMarkedContent(GfxState *state);
+  virtual void beginMarkedContent(char *name, Dict *properties);
+  virtual void beginMarkedContent(char *name, Object *dictRef );
   virtual void markPoint(char *name);
   virtual void markPoint(char *name, Dict *properties);
 
poppler_marked_content.diff (2,310 bytes)   

fschmid

2015-12-07 21:33

developer   ~0037867

Uploaded the original patch to poppler 0.19.4, no idea if it still can be applied.

Kunda

2015-12-08 06:43

updater   ~0037872

Looks like some of the patch was implemented:
http://cgit.freedesktop.org/poppler/poppler/tree/poppler/Gfx.cc#n5167

Kunda

2016-01-28 22:24

updater   ~0038482

william, if you get a moment, could you provide any feedback here? Perhaps if needed help with implementing the rest of the functionality that Franz wrote into an updated patch ?

christoph_s

2016-02-20 08:12

developer   ~0038849

JFYI: https://helpx.adobe.com/indesign/using/placing-graphics.html#control_layer_visibility_in_imported_images

Issue History

Date Modified Username Field Change
2013-04-19 04:53 christoph_s New Issue
2013-04-19 04:53 christoph_s Status new => assigned
2013-04-19 04:53 christoph_s Assigned To => fschmid
2013-04-19 09:03 jghali Note Added: 0030091
2013-04-19 19:25 fschmid Note Added: 0030094
2013-04-20 10:44 jghali Severity minor => feature
2015-12-07 18:43 Kunda Note Added: 0037855
2015-12-07 18:43 Kunda Tag Attached: upstream
2015-12-07 21:32 fschmid File Added: poppler_marked_content.diff
2015-12-07 21:33 fschmid Note Added: 0037867
2015-12-08 06:43 Kunda Note Added: 0037872
2016-01-28 22:24 Kunda Note Added: 0038482
2016-02-20 08:12 christoph_s Note Added: 0038849