View Issue Details

IDProjectCategoryView StatusLast Update
0014824ScribusPDFpublic2017-05-27 15:59
Reporterdockattt Assigned To 
PrioritynormalSeveritytextReproducibilityalways
Status newResolutionopen 
Product Version1.5.3 
Summary0014824: add option to output text with pdf link annotations
Descriptionwhen pdf link annotations are placed in documents and subsequently outputed into a pdf file any text that has been put into the link's text frame does not get written. It would be useful to add an option that allowed the text to be output with the text. Doing so will eliminate work for the user. If the text in the link says what the user wants in the pdf then they should be able to use the link as the text source.

The patch file adds this option. In the Export PDF tab there is a new tab called Item Config. In it are 3 check boxes that if clicked will change how the link's text is outputted to the pdf for 3 different types of links. There is an additional option that allows the user to target individual pdf links. If the attribute writepdftext is added with a yes or no value that value will take precedence over the behavior set in the tab. These new options are stored in the .sla file with the other pdf options.

This will be great to have. The last project I worked on I had to make 40 links to place under individual text lines. This would have eliminated that work. Future projects might entail doing even more then that! :D
Steps To Reproducerun with patch and set options. Examine the pdf files outputted. Links still work and text is there. Or not there if turned off or overridden with the writepdftext attribute. Enjoy!
TagsNo tags attached.
PatchYes

Activities

dockattt

2017-05-27 15:59

reporter  

writepdflinktext.patch (24,142 bytes)   
Index: Scribus/scribus/pdflib_core.cpp
===================================================================
--- Scribus/scribus/pdflib_core.cpp	(revision 22047)
+++ Scribus/scribus/pdflib_core.cpp	(working copy)
@@ -4513,7 +4513,34 @@
 				}
 				if (!PDF_Annotation(ite, PNr))
 					return false;
-				break;
+
+				if(ite->annotation().Type()==Annotation::Link){
+					
+
+					ObjectAttribute oa = ite->getObjectAttribute(QString("writepdftext"));
+					enum{NOTSET, WPTYES, WPTNO};
+					int pwtoverride = NOTSET;
+					QString pwtflag = oa.value.toLower().trimmed();
+					if(pwtflag == QString("yes")) 
+						pwtoverride = WPTYES;
+					else if(pwtflag == QString("no")) 
+						pwtoverride = WPTNO;
+					
+					const int actiontype = ite->annotation().ActionType();
+
+					if((actiontype == Annotation::Action_GoTo && (Options.WriteLinkAnnotationText || pwtoverride == WPTYES)) ||				
+					   (actiontype == Annotation::Action_URI && (Options.WriteURIAnnotationText || pwtoverride == WPTYES)) ||
+					   (actiontype == Annotation::Action_GoToR_FileRel && (Options.WriteFileAnnotationText || pwtoverride == WPTYES)) ||
+					   (actiontype == Annotation::Action_GoToR_FileAbs && (Options.WriteFileAnnotationText || pwtoverride == WPTYES))){
+						if(pwtoverride == WPTNO) break;
+					}
+					else{	
+					 	break;
+					}
+
+				}
+				else break;
+			
 			}
 			tmp += "q\n";
 			if (((ite->GrMask > 0) || (ite->fillTransparency() != 0) || (ite->fillBlendmode() != 0)) && ((Options.Version >= PDFOptions::PDFVersion_14) || (Options.Version == PDFOptions::PDFVersion_X4) ))
Index: Scribus/scribus/pdfoptions.h
===================================================================
--- Scribus/scribus/pdfoptions.h	(revision 22047)
+++ Scribus/scribus/pdfoptions.h	(working copy)
@@ -169,6 +169,9 @@
 	QString openAction;
 	int pageRangeSelection;
 	QString pageRangeString;
+	bool WriteLinkAnnotationText;
+	bool WriteURIAnnotationText;
+	bool WriteFileAnnotationText;
 };
 
 #endif
Index: Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
===================================================================
--- Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp	(revision 22047)
+++ Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp	(working copy)
@@ -3177,6 +3177,9 @@
 	doc->pdfOptions().openAfterExport     = attrs.valueAsBool("openAfterExport", false);
 	doc->pdfOptions().PageLayout    = attrs.valueAsInt("PageLayout", 0);
 	doc->pdfOptions().openAction    = attrs.valueAsString("openAction", "");
+	doc->pdfOptions().WriteLinkAnnotationText = attrs.valueAsBool("WriteLinkAnnotationText", false);
+	doc->pdfOptions().WriteURIAnnotationText = attrs.valueAsBool("WriteURIAnnotationText", false);
+	doc->pdfOptions().WriteFileAnnotationText = attrs.valueAsBool("WriteFileAnnotationText", false);
 
 	QStringRef tagName = reader.name();
 	while (!reader.atEnd() && !reader.hasError())
Index: Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
===================================================================
--- Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp	(revision 22047)
+++ Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp	(working copy)
@@ -1158,6 +1158,9 @@
 	docu.writeAttribute("openAfterExport", static_cast<int>(m_Doc->pdfOptions().openAfterExport));
 	docu.writeAttribute("PageLayout", m_Doc->pdfOptions().PageLayout);
 	docu.writeAttribute("openAction", m_Doc->pdfOptions().openAction);
+	docu.writeAttribute("WriteLinkAnnotationText", static_cast<int>(m_Doc->pdfOptions().WriteLinkAnnotationText));
+	docu.writeAttribute("WriteURIAnnotationText", static_cast<int>(m_Doc->pdfOptions().WriteURIAnnotationText));
+	docu.writeAttribute("WriteFileAnnotationText", static_cast<int>(m_Doc->pdfOptions().WriteFileAnnotationText));
 
 	const QList<QString>& embedList = m_Doc->pdfOptions().EmbedList;
 	for (int pdoF = 0; pdoF < embedList.count(); ++pdoF)
Index: Scribus/scribus/prefsmanager.cpp
===================================================================
--- Scribus/scribus/prefsmanager.cpp	(revision 22047)
+++ Scribus/scribus/prefsmanager.cpp	(working copy)
@@ -496,6 +496,9 @@
 	appPrefs.pdfPrefs.openAfterExport = false;
 	appPrefs.pdfPrefs.PageLayout = PDFOptions::SinglePage;
 	appPrefs.pdfPrefs.openAction = "";
+	appPrefs.pdfPrefs.WriteLinkAnnotationText = false;
+	appPrefs.pdfPrefs.WriteURIAnnotationText = false;
+	appPrefs.pdfPrefs.WriteFileAnnotationText = false;
 	appPrefs.imageCachePrefs.cacheEnabled = false;
 	appPrefs.imageCachePrefs.maxCacheSizeMiB = 1000;
 	appPrefs.imageCachePrefs.maxCacheEntries = 1000;
Index: Scribus/scribus/ui/pdfexportdialog.cpp
===================================================================
--- Scribus/scribus/ui/pdfexportdialog.cpp	(revision 22047)
+++ Scribus/scribus/ui/pdfexportdialog.cpp	(working copy)
@@ -421,6 +421,10 @@
 			}
 		}
 	}
+	m_opts.WriteLinkAnnotationText = Options->WriteLinkAnnotationText->isChecked();
+	m_opts.WriteURIAnnotationText = Options->WriteURIAnnotationText->isChecked();
+	m_opts.WriteFileAnnotationText = Options->WriteFileAnnotationText->isChecked();
+
 }
 
 const QString PDFExportDialog::cmsDescriptor()
Index: Scribus/scribus/ui/tabpdfoptions.cpp
===================================================================
--- Scribus/scribus/ui/tabpdfoptions.cpp	(revision 22047)
+++ Scribus/scribus/ui/tabpdfoptions.cpp	(working copy)
@@ -720,6 +720,9 @@
 		bleedLeftLabel->setText( tr( "Inside:" ) );
 		bleedRightLabel->setText( tr( "Outside:" ) );
 	}
+	WriteLinkAnnotationText->setChecked(Opts.WriteLinkAnnotationText);
+	WriteFileAnnotationText->setChecked(Opts.WriteFileAnnotationText);
+	WriteURIAnnotationText->setChecked(Opts.WriteURIAnnotationText);
 }
 
 void TabPDFOptions::handleCompressionMethod(int ind)
@@ -762,6 +765,9 @@
 	pdfOptions.bleeds.setLeft(BleedLeft->value() / unitRatio);
 	pdfOptions.bleeds.setRight(BleedRight->value() / unitRatio);
 	pdfOptions.doClip = ClipMarg->isChecked();
+	pdfOptions.WriteLinkAnnotationText = WriteLinkAnnotationText->isChecked();
+	pdfOptions.WriteFileAnnotationText = WriteFileAnnotationText->isChecked();
+	pdfOptions.WriteURIAnnotationText = WriteURIAnnotationText->isChecked();
 	if (Encry->isChecked())
 	{
 		int Perm = -64;
Index: Scribus/scribus/ui/tabpdfoptions.ui
===================================================================
--- Scribus/scribus/ui/tabpdfoptions.ui	(revision 22047)
+++ Scribus/scribus/ui/tabpdfoptions.ui	(working copy)
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>657</width>
-    <height>549</height>
+    <height>583</height>
    </rect>
   </property>
   <property name="currentIndex">
@@ -21,18 +21,9 @@
     <property name="spacing">
      <number>5</number>
     </property>
-    <property name="leftMargin">
+    <property name="margin">
      <number>10</number>
     </property>
-    <property name="topMargin">
-     <number>10</number>
-    </property>
-    <property name="rightMargin">
-     <number>10</number>
-    </property>
-    <property name="bottomMargin">
-     <number>10</number>
-    </property>
     <item>
      <layout class="QHBoxLayout" name="horizontalLayout">
       <property name="spacing">
@@ -47,18 +38,9 @@
          <property name="spacing">
           <number>5</number>
          </property>
-         <property name="leftMargin">
+         <property name="margin">
           <number>10</number>
          </property>
-         <property name="topMargin">
-          <number>10</number>
-         </property>
-         <property name="rightMargin">
-          <number>10</number>
-         </property>
-         <property name="bottomMargin">
-          <number>10</number>
-         </property>
          <item>
           <widget class="QRadioButton" name="AllPages">
            <property name="text">
@@ -183,18 +165,9 @@
          <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
         </property>
         <layout class="QGridLayout" name="fileOptionsLayout">
-         <property name="leftMargin">
+         <property name="margin">
           <number>10</number>
          </property>
-         <property name="topMargin">
-          <number>10</number>
-         </property>
-         <property name="rightMargin">
-          <number>10</number>
-         </property>
-         <property name="bottomMargin">
-          <number>10</number>
-         </property>
          <property name="spacing">
           <number>5</number>
          </property>
@@ -327,18 +300,9 @@
        <string>Image Quality Settings</string>
       </property>
       <layout class="QGridLayout" name="imageQualityLayout">
-       <property name="leftMargin">
+       <property name="margin">
         <number>10</number>
        </property>
-       <property name="topMargin">
-        <number>10</number>
-       </property>
-       <property name="rightMargin">
-        <number>10</number>
-       </property>
-       <property name="bottomMargin">
-        <number>10</number>
-       </property>
        <property name="spacing">
         <number>5</number>
        </property>
@@ -470,18 +434,9 @@
     <property name="spacing">
      <number>5</number>
     </property>
-    <property name="leftMargin">
+    <property name="margin">
      <number>10</number>
     </property>
-    <property name="topMargin">
-     <number>10</number>
-    </property>
-    <property name="rightMargin">
-     <number>10</number>
-    </property>
-    <property name="bottomMargin">
-     <number>10</number>
-    </property>
     <item>
      <widget class="QGroupBox" name="groupFont">
       <property name="title">
@@ -488,18 +443,9 @@
        <string>Embedding</string>
       </property>
       <layout class="QVBoxLayout" name="groupFontLayout">
-       <property name="leftMargin">
+       <property name="margin">
         <number>10</number>
        </property>
-       <property name="topMargin">
-        <number>10</number>
-       </property>
-       <property name="rightMargin">
-        <number>10</number>
-       </property>
-       <property name="bottomMargin">
-        <number>10</number>
-       </property>
        <item>
         <layout class="QHBoxLayout" name="horizontalLayout_5">
          <item>
@@ -645,18 +591,9 @@
     <string>E&amp;xtras</string>
    </attribute>
    <layout class="QGridLayout" name="gridLayout_4">
-    <property name="leftMargin">
+    <property name="margin">
      <number>10</number>
     </property>
-    <property name="topMargin">
-     <number>10</number>
-    </property>
-    <property name="rightMargin">
-     <number>10</number>
-    </property>
-    <property name="bottomMargin">
-     <number>10</number>
-    </property>
     <property name="spacing">
      <number>5</number>
     </property>
@@ -897,18 +834,9 @@
     <property name="spacing">
      <number>5</number>
     </property>
-    <property name="leftMargin">
+    <property name="margin">
      <number>10</number>
     </property>
-    <property name="topMargin">
-     <number>10</number>
-    </property>
-    <property name="rightMargin">
-     <number>10</number>
-    </property>
-    <property name="bottomMargin">
-     <number>10</number>
-    </property>
     <item>
      <widget class="QGroupBox" name="groupDisplay">
       <property name="title">
@@ -918,35 +846,17 @@
        <property name="spacing">
         <number>5</number>
        </property>
-       <property name="leftMargin">
+       <property name="margin">
         <number>10</number>
        </property>
-       <property name="topMargin">
-        <number>10</number>
-       </property>
-       <property name="rightMargin">
-        <number>10</number>
-       </property>
-       <property name="bottomMargin">
-        <number>10</number>
-       </property>
        <item>
         <layout class="QHBoxLayout" name="horizontalLayout_7">
          <property name="spacing">
           <number>5</number>
          </property>
-         <property name="leftMargin">
+         <property name="margin">
           <number>0</number>
          </property>
-         <property name="topMargin">
-          <number>0</number>
-         </property>
-         <property name="rightMargin">
-          <number>0</number>
-         </property>
-         <property name="bottomMargin">
-          <number>0</number>
-         </property>
          <item>
           <widget class="QGroupBox" name="pageLayout">
            <property name="title">
@@ -956,18 +866,9 @@
             <property name="spacing">
              <number>5</number>
             </property>
-            <property name="leftMargin">
+            <property name="margin">
              <number>10</number>
             </property>
-            <property name="topMargin">
-             <number>10</number>
-            </property>
-            <property name="rightMargin">
-             <number>10</number>
-            </property>
-            <property name="bottomMargin">
-             <number>10</number>
-            </property>
             <item>
              <widget class="QRadioButton" name="singlePage">
               <property name="text">
@@ -1008,18 +909,9 @@
             <property name="spacing">
              <number>5</number>
             </property>
-            <property name="leftMargin">
+            <property name="margin">
              <number>10</number>
             </property>
-            <property name="topMargin">
-             <number>10</number>
-            </property>
-            <property name="rightMargin">
-             <number>10</number>
-            </property>
-            <property name="bottomMargin">
-             <number>10</number>
-            </property>
             <item>
              <widget class="QRadioButton" name="useViewDefault">
               <property name="text">
@@ -1090,18 +982,9 @@
           <property name="spacing">
            <number>5</number>
           </property>
-          <property name="leftMargin">
+          <property name="margin">
            <number>10</number>
           </property>
-          <property name="topMargin">
-           <number>10</number>
-          </property>
-          <property name="rightMargin">
-           <number>10</number>
-          </property>
-          <property name="bottomMargin">
-           <number>10</number>
-          </property>
           <item>
            <widget class="QLabel" name="actionLabel">
             <property name="text">
@@ -1138,18 +1021,9 @@
     <property name="spacing">
      <number>5</number>
     </property>
-    <property name="leftMargin">
+    <property name="margin">
      <number>10</number>
     </property>
-    <property name="topMargin">
-     <number>10</number>
-    </property>
-    <property name="rightMargin">
-     <number>10</number>
-    </property>
-    <property name="bottomMargin">
-     <number>10</number>
-    </property>
     <item>
      <widget class="QCheckBox" name="Encry">
       <property name="text">
@@ -1169,18 +1043,9 @@
        <string>Passwords</string>
       </property>
       <layout class="QGridLayout" name="groupPassLayout">
-       <property name="leftMargin">
+       <property name="margin">
         <number>10</number>
        </property>
-       <property name="topMargin">
-        <number>10</number>
-       </property>
-       <property name="rightMargin">
-        <number>10</number>
-       </property>
-       <property name="bottomMargin">
-        <number>10</number>
-       </property>
        <property name="spacing">
         <number>5</number>
        </property>
@@ -1236,18 +1101,9 @@
        <property name="spacing">
         <number>5</number>
        </property>
-       <property name="leftMargin">
+       <property name="margin">
         <number>10</number>
        </property>
-       <property name="topMargin">
-        <number>10</number>
-       </property>
-       <property name="rightMargin">
-        <number>10</number>
-       </property>
-       <property name="bottomMargin">
-        <number>10</number>
-       </property>
        <item>
         <widget class="QCheckBox" name="PrintSec">
          <property name="text">
@@ -1302,18 +1158,9 @@
     <property name="spacing">
      <number>5</number>
     </property>
-    <property name="leftMargin">
+    <property name="margin">
      <number>10</number>
     </property>
-    <property name="topMargin">
-     <number>10</number>
-    </property>
-    <property name="rightMargin">
-     <number>10</number>
-    </property>
-    <property name="bottomMargin">
-     <number>10</number>
-    </property>
     <item>
      <widget class="QGroupBox" name="ColorGroup">
       <property name="title">
@@ -1323,18 +1170,9 @@
        <property name="spacing">
         <number>5</number>
        </property>
-       <property name="leftMargin">
+       <property name="margin">
         <number>10</number>
        </property>
-       <property name="topMargin">
-        <number>10</number>
-       </property>
-       <property name="rightMargin">
-        <number>10</number>
-       </property>
-       <property name="bottomMargin">
-        <number>10</number>
-       </property>
        <item>
         <widget class="QLabel" name="label_16">
          <property name="text">
@@ -1387,18 +1225,9 @@
        <string>Rendering Settings</string>
       </property>
       <layout class="QGridLayout" name="lpiGroupLayout">
-       <property name="leftMargin">
+       <property name="margin">
         <number>10</number>
        </property>
-       <property name="topMargin">
-        <number>10</number>
-       </property>
-       <property name="rightMargin">
-        <number>10</number>
-       </property>
-       <property name="bottomMargin">
-        <number>10</number>
-       </property>
        <property name="spacing">
         <number>5</number>
        </property>
@@ -1506,18 +1335,9 @@
        <string>Solid Colors:</string>
       </property>
       <layout class="QGridLayout" name="solidColorsGroupLayout">
-       <property name="leftMargin">
+       <property name="margin">
         <number>10</number>
        </property>
-       <property name="topMargin">
-        <number>10</number>
-       </property>
-       <property name="rightMargin">
-        <number>10</number>
-       </property>
-       <property name="bottomMargin">
-        <number>10</number>
-       </property>
        <property name="spacing">
         <number>5</number>
        </property>
@@ -1581,18 +1401,9 @@
        <string>Images:</string>
       </property>
       <layout class="QGridLayout" name="imageProfileGroupLayout">
-       <property name="leftMargin">
+       <property name="margin">
         <number>10</number>
        </property>
-       <property name="topMargin">
-        <number>10</number>
-       </property>
-       <property name="rightMargin">
-        <number>10</number>
-       </property>
-       <property name="bottomMargin">
-        <number>10</number>
-       </property>
        <property name="spacing">
         <number>5</number>
        </property>
@@ -1680,18 +1491,9 @@
     <property name="spacing">
      <number>5</number>
     </property>
-    <property name="leftMargin">
+    <property name="margin">
      <number>10</number>
     </property>
-    <property name="topMargin">
-     <number>10</number>
-    </property>
-    <property name="rightMargin">
-     <number>10</number>
-    </property>
-    <property name="bottomMargin">
-     <number>10</number>
-    </property>
     <item>
      <widget class="QGroupBox" name="MarkGroup">
       <property name="title">
@@ -1698,18 +1500,9 @@
        <string>Printer Marks</string>
       </property>
       <layout class="QGridLayout" name="markGroupLayout">
-       <property name="leftMargin">
+       <property name="margin">
         <number>10</number>
        </property>
-       <property name="topMargin">
-        <number>10</number>
-       </property>
-       <property name="rightMargin">
-        <number>10</number>
-       </property>
-       <property name="bottomMargin">
-        <number>10</number>
-       </property>
        <property name="spacing">
         <number>5</number>
        </property>
@@ -1785,18 +1578,9 @@
        <string>Bleed Settings</string>
       </property>
       <layout class="QGridLayout" name="bleedGroupLayout">
-       <property name="leftMargin">
+       <property name="margin">
         <number>10</number>
        </property>
-       <property name="topMargin">
-        <number>10</number>
-       </property>
-       <property name="rightMargin">
-        <number>10</number>
-       </property>
-       <property name="bottomMargin">
-        <number>10</number>
-       </property>
        <property name="spacing">
         <number>5</number>
        </property>
@@ -1856,18 +1640,9 @@
        <string>PDF/X Output Intent</string>
       </property>
       <layout class="QGridLayout" name="X3GroupLayout">
-       <property name="leftMargin">
+       <property name="margin">
         <number>10</number>
        </property>
-       <property name="topMargin">
-        <number>10</number>
-       </property>
-       <property name="rightMargin">
-        <number>10</number>
-       </property>
-       <property name="bottomMargin">
-        <number>10</number>
-       </property>
        <property name="spacing">
         <number>5</number>
        </property>
@@ -1919,6 +1694,69 @@
     </item>
    </layout>
   </widget>
+  <widget class="QWidget" name="tab">
+   <attribute name="title">
+    <string>Item Config</string>
+   </attribute>
+   <attribute name="toolTip">
+    <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Configure the writing of pdf items&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+   </attribute>
+   <widget class="QCheckBox" name="WriteLinkAnnotationText">
+    <property name="geometry">
+     <rect>
+      <x>10</x>
+      <y>20</y>
+      <width>175</width>
+      <height>22</height>
+     </rect>
+    </property>
+    <property name="toolTip">
+     <string/>
+    </property>
+    <property name="text">
+     <string>Write link annotation text</string>
+    </property>
+   </widget>
+   <widget class="QCheckBox" name="WriteURIAnnotationText">
+    <property name="geometry">
+     <rect>
+      <x>10</x>
+      <y>50</y>
+      <width>181</width>
+      <height>22</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Write URI annotation text</string>
+    </property>
+   </widget>
+   <widget class="QCheckBox" name="WriteFileAnnotationText">
+    <property name="geometry">
+     <rect>
+      <x>10</x>
+      <y>80</y>
+      <width>181</width>
+      <height>22</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Write file annotation text</string>
+    </property>
+   </widget>
+   <widget class="QLabel" name="Overridenote">
+    <property name="geometry">
+     <rect>
+      <x>10</x>
+      <y>100</y>
+      <width>281</width>
+      <height>71</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;(Individual items can be controlled by using the &lt;/p&gt;&lt;p align=&quot;center&quot;&gt;writepdftext attribute with a value of yes or no)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+    </property>
+   </widget>
+  </widget>
  </widget>
  <customwidgets>
   <customwidget>
writepdflinktext.patch (24,142 bytes)   

Issue History

Date Modified Username Field Change
2017-05-27 15:59 dockattt New Issue
2017-05-27 15:59 dockattt File Added: writepdflinktext.patch