View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0015513 | Scribus | public | 2018-12-16 17:30 | 2021-09-24 08:47 | |
Reporter | dockattt | Assigned To | |||
Priority | normal | Severity | feature | Reproducibility | always |
Status | new | Resolution | open | ||
Product Version | 1.5.4.svn | ||||
Summary | 0015513: Concept: add ability to link pdf links to objects | ||||
Description | ok, this is a concept that I think could be useful. The idea is to add the ability to link pdf links to a specific object in the document. Say, for example, I have a pdf link on page 1 of the document. I want that link to jump to wherever a text field with the name of "test" is at in the document. Instead of setting the coordinates through the gui I add an attribute to the link called "ltarget". For the value I use "test", the name of the text field. When the pdf is written the code looks up where "test" is at and calculates the coordinates at pdf write time. I know that this could be useful for myself in that I have frequently updated documents that have required me to update links. And these links are usually aiming for a specific thing in the document. If the idea seems good and worthy of adding to Scribus then perhaps it can be enhanced further by moving from using the attribute interface to extending the link dialog to offer this as an option? | ||||
Steps To Reproduce | The attached patch functions by: 1. adding a "ltarget" attribute to a PDF link 2. giving the attribute a value of that corresponds to an objects name. 3. It looks at this attribute at pdf write time and if it finds the object it calculates the coordinates. | ||||
Additional Information | works in my pdf tests. I have regular links and "ltarget" links in the same document. No problems seen yet. | ||||
Tags | patch | ||||
Patch | Yes | ||||
|
linkobject.patch (1,402 bytes)
Index: Scribus/scribus/pdflib_core.cpp =================================================================== --- Scribus/scribus/pdflib_core.cpp (revision 22789) +++ Scribus/scribus/pdflib_core.cpp (working copy) @@ -9044,11 +9044,36 @@ PutDoc("/Subtype /Link\n"); if (ite->annotation().ActionType() == Annotation::Action_GoTo) { + QString name = ite->getObjectAttribute(QString("ltarget")).value; + int ownpage = -1; + QString laction = QString("%1 %2 0"); + if(name != ""){ + ScribusDoc * sdoc = ScCore->primaryMainWindow()->doc; + PageItem * linked = sdoc->getItemFromName(name); + if(linked != nullptr){ + ownpage = linked->OwnPage; + ScPage * spage = sdoc->Pages->at(ownpage); + int poffx = spage->xOffset(); + int poffy = spage->yOffset(); + int lx = linked->xPos() - poffx; + int ly = spage->height()-(linked->yPos() - poffy); + laction = laction.arg(lx).arg(ly); + } + } + PutDoc("/Dest /"+NDnam+Pdf::toPdf(NDnum)+"\n"); PdfDest de; de.Name = NDnam+Pdf::toPdf(NDnum); - de.PageNr = ite->annotation().Ziel(); - de.Act = ite->annotation().Action(); + + if(ownpage == -1){ + de.PageNr = ite->annotation().Ziel(); + de.Act = ite->annotation().Action(); + } + else{ + de.PageNr = ownpage; + de.Act = laction; + } + NamedDest.append(de); NDnum++; } |
|
Interesting and the patch is simple... but it doesnt include any new UI to input the destination. There is no need for it ? |