Skip to content

PUBLISH publishes a sheet list (.dsd): the sheets of many drawings into one PDF, a bookmark per sheet - #3580

Merged
HakanSeven12 merged 1 commit into
HakanSeven12:mainfrom
ohagmann:feat/publish-sheet-list
Nov 24, 2026
Merged

HakanSeven12 merged 1 commit into
HakanSeven12:mainfrom
ohagmann:feat/publish-sheet-list

Conversation

@ohagmann

Copy link
Copy Markdown
Contributor

What

PUBLISH (and -PUBLISH) with a .dsd path publishes a sheet list: the sheets of many drawings, in the list's
order, into one PDF with a bookmark per sheet, or into a PDF per sheet. A .dsd is the drawing set description
AutoCAD's and BricsCAD's PUBLISH save and read, so existing sheet lists and the tools that write them work as they
are. Today PUBLISH covers the layouts of the current drawing only (#1124).

PUBLISH "C:\sets\set.dsd"
OpenCADStudio --batch publish.scr      (publish.scr: -PUBLISH "set.dsd"; no drawing needs to be open)

Sheet list

  • [DWF6Sheet:<name>] per sheet: DWG= (relative to the list's folder; Windows separators accepted elsewhere),
    Layout= (Model for model space), optional Setup= (a named page setup of the drawing to plot with instead of
    the layout's own; one imported from another drawing is refused with a message).
  • [Target] Type=6 one PDF at DWF=; Type=5 a PDF per sheet, named after the sheet, in OUT=. Other targets
    (plotter, DWF) are refused.
  • [PdfOptions] CreateBookmarks=FALSE leaves the bookmarks out; other keys are ignored.
  • UTF-8, UTF-16 with BOM and ANSI (Windows-1252) files are read.

How it runs

  • The drawings open one at a time through the same OPEN a script uses (rows queued at the front of the script
    queue, PUBLISHNEXT between two drawings), so each sheet plots exactly as it plots from its own drawing, with its
    own page setup, from the command line, a script or --batch.
  • 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 (plot-date fields are
    stamped, nothing is saved).
  • Each sheet is reported with its paper size, or with the reason it was not published (drawing missing, no such
    layout or page setup); the other sheets publish all the same and a batch run ends with status 1.

PDF

  • io::pdf_publish writes the PDF as the drawings go: each drawing's rendered pages and the objects they use are
    renumbered into the output file at once; the page tree, a flat bookmark per sheet (opens its whole page, /Fit)
    and the layer list follow at the end. The file replaces the target only when complete; an aborted run leaves no
    partial file.
  • Pages inherit Resources/MediaBox/CropBox/Rotate from their old page tree before they leave it.
  • Layers of the same name are one optional-content group across all drawings, so the viewer's layer panel lists each
    layer once and hides it on every sheet.
  • 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 … ALL per drawing, and every page renders pixel-identical to that.

Other changes

  • print_all_pages' loop is plot_layout_pages, which takes an optional page setup beside each layout and no longer
    forces paper space onto Model. Print All behaves as before.
  • pdf_export::render_pdf_document returns the rendered lopdf::Document before serialisation;
    render_pdf_bytes_impl uses it.
  • New messages in every locale's catalog; the PUBLISH wiki page describes the typed forms and sheet lists.

Tests

  • io::dsd::tests: sections, order, relative and Windows paths, targets, bookmarks off, encodings, refusals.
  • io::pdf_publish::tests: two documents with inherited resources become one PDF with ordered bookmarks, page sizes
    kept, shared layer groups, valid parents; no file without finish, none on an empty set; escaping.
  • app::sheet_publish::tests: --batch run over two drawings with a missing drawing and a missing layout (reported,
    the rest published, status 1, drawings closed, no lock files); typed PUBLISH with an open drawing and a
    per-sheet target.

…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.
@HakanSeven12
HakanSeven12 merged commit 942e010 into HakanSeven12:main Nov 24, 2026
HakanSeven12 added a commit that referenced this pull request Nov 24, 2026
…SH docs name no other product

Follow-up to #3584, #3580.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants