Repository navigation
PDF export carries hyperlinks; in a published set a link to a sheet opens its page - #3583
Merged
Merged
Conversation
…to one PDF, a bookmark per sheet PUBLISH (and -PUBLISH) with a .dsd path reads the sheet list AutoCAD's and BricsCAD's PUBLISH save, and publishes its sheets in its order: - each [DWF6Sheet:<name>] names a drawing (DWG=, relative to the list's folder), a layout (Layout=, Model for model space) and optionally a named page setup of the drawing (Setup=); - [Target] Type=6 writes one PDF (DWF=), Type=5 a PDF per sheet, named after it, in the OUT= folder; other targets are refused; - [PdfOptions] CreateBookmarks=FALSE leaves the bookmarks out. The drawings open one at a time through the OPEN a script uses: rows queued at the front of the script queue, with PUBLISHNEXT between two drawings. So each sheet plots exactly as it does from its own drawing, with its own page setup, from the command line, a script or --batch (where no drawing needs to be open). A drawing that is already open is plotted as it is and stays open; one opened for the list takes no edit lease, so it leaves no lock file beside the drawing, and is closed unsaved once its sheets are plotted. Each sheet is reported with its paper size or the reason it was not published; the other sheets publish all the same, and a batch run ends with status 1. The PDF is written as the drawings go (io::pdf_publish): each drawing's rendered pages and what they use are renumbered into the output file at once; the page tree, a flat bookmark per sheet that opens its whole page, and the layer list follow at the end, and the file replaces the target only when it is complete. Layers of the same name are one optional-content group across all drawings, so a viewer's layer panel lists each once. Memory holds one drawing at a time: a real-world set of 471 sheets (A2 and A0) publishes in 20 s at 0.9 GB peak, the same as one EXPORTPDF per drawing, and every page renders identical to it. Print All's page loop takes a page setup beside each layout (plot_layout_pages) and no longer forces paper space onto Model. The new messages are in every locale's catalog; the PUBLISH wiki page describes the typed forms and sheet lists.
…pens its page The PDF export dropped every hyperlink. Now an object's hyperlink becomes a link annotation over the object on the page, as the reference application exports them: - the links of the plotted layout's own objects and of the model-space objects a viewport of the layout shows, on layers that plot; block members and attributes take no part (the reference application exports none of theirs either); - the area is the object's plotted ink; an object that plots none - a text of spaces fitted over a table row, the way a table of contents links its rows - covers its own extent (a fit or aligned text from 0.226 of its height below the baseline to 0.834 above, as the reference application sizes it); through a viewport the area is mapped onto the sheet and cut to the viewport; on the page it follows the plot's rotation, scale and window; - a web or mail address opens as a URI; a file address as a relative reference or a file: URI, %-escaped. A link to a page written into the same file opens that page, through a named destination (catalog /Names /Dests), so it can point forward: - PUBLISH of a sheet list names every sheet's page (OcsSheet000001, ...) and resolves each link against the list: the drawing (relative to HYPERLINKBASE or the drawing's folder, with Windows separators when needed) and its named location as a layout, also the layout of a `view,layout` location; without a matching layout the drawing's first sheet. Names are written at the end of the set, after all pages; - an export of several layouts of one drawing (EXPORTPDF ... ALL, Print All, PUBLISH <file.pdf>) links a location naming one of those layouts to its page. On a real-world set of 471 sheets with ten table-of-contents pages whose 189 rows carry such links, every row opens the page its page number names, the same as the reference application's own publish of that set; the set publishes in the same time and memory as before.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Builds on #3580 (PUBLISH from a sheet list); the first commit of this branch is that PR's.
What
The PDF export dropped every hyperlink. Now an object's hyperlink becomes a link annotation over the object on the
page, and in a published set a link to one of its sheets opens that sheet's page. The typical use is a table of
contents: each row links to its sheet's drawing and layout, and a click on the row in the PDF jumps there.
Which links, over what area
As the reference application exports them (checked against its PDF output):
layers that plot; block members and attributes take no part (the reference application exports none of theirs
either, nor those on layers that do not plot);
a table of contents can link its rows without showing anything — covers its own extent (a fit or aligned text from
0.226 of its height below the baseline to 0.834 above, as the reference application sizes it). Through a viewport
the area is mapped onto the sheet and cut to the viewport; on the page it follows the plot's rotation, scale and
window;
file:URI, %-escaped.Links inside the file
A link to a page written into the same file opens that page through a named destination (catalog
/Names /Dests),so it can point forward to a page not yet written:
PUBLISH <list.dsd>names every sheet's page (OcsSheet000001, …) and resolves each link against the list: thedrawing (relative to
HYPERLINKBASEor the drawing's folder, with Windows separators when needed) and its namedlocation as a layout, also the layout of a
view,layoutlocation; without a matching layout the drawing's firstsheet. The names are written at the end of the set. Every sheet has its name, so other documents can link to a
sheet too (
set.pdf#OcsSheet000042).EXPORTPDF … ALL, Print All,PUBLISH <file.pdf>) links a locationnaming one of those layouts to its page.
On a real-world set of 471 sheets with ten table-of-contents pages whose 189 rows carry such links, every row opens
the page its page number names — the same pages the reference application's own publish of that set links to — and
the set publishes in the same time and memory as before.
Tests
io::pdf_export::tests::links_cover_their_objects_and_open_their_targets: area from plotted ink or own bounds, URIvs destination, a link without address or target dropped, quarter-turned page, plot window.
io::pdf_export::tests::links_become_annotations_and_named_pages,link_addresses_become_uris.io::pdf_publish::tests::drawings_become_one_pdf_with_a_bookmark_per_sheet_and_shared_layers: the name tree.app::update::file::plot_link_tests: links between layouts of one drawing, by name in any case,view,layout,the drawing's own path.
app::sheet_publish::tests::a_link_to_a_sheet_of_the_list_opens_its_page: a--batchPUBLISH of two drawings, atext of spaces in one linked to the other by a relative path: the PDF row opens the second page; a web link stays a
URI.