Skip to content

Comments

fix: Add DucModelElement support and remove BlockManager from PDF gen…#179

Merged
jorgedanisc merged 1 commit intodevfrom
jorgedanisc
Feb 9, 2026
Merged

fix: Add DucModelElement support and remove BlockManager from PDF gen…#179
jorgedanisc merged 1 commit intodevfrom
jorgedanisc

Conversation

@jorgedanisc
Copy link
Contributor

…eration.

@jorgedanisc jorgedanisc self-assigned this Feb 9, 2026
Copilot AI review requested due to automatic review settings February 9, 2026 22:32
@jorgedanisc jorgedanisc merged commit 6b6b457 into dev Feb 9, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 9, 2026

🎉 This PR is included in version 2.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to extend the DUC→PDF pipeline with initial DucModelElement plumbing while removing BlockManager from the PDF generation flow.

Changes:

  • Added DucModelElement handling in common “element base” accessors and scaling/bounds calculations.
  • Removed BlockManager from DucToPdfBuilder and element streaming call paths.
  • Simplified parts of resource streaming (removed unused helpers/fields; some dimensions now hard-coded).

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/ducpdf/src/duc2pdf/src/utils/style_resolver.rs Removes an unused helper for applying base element styles.
packages/ducpdf/src/duc2pdf/src/streaming/stream_resources.rs Simplifies resource streamer state and dimension handling; adjusts PDF/SVG processing.
packages/ducpdf/src/duc2pdf/src/streaming/stream_elements.rs Removes BlockManager plumb-through and adds partial DucModelElement branches.
packages/ducpdf/src/duc2pdf/src/streaming/pdf_linear.rs Removes unused intermediate variables during path segment creation.
packages/ducpdf/src/duc2pdf/src/scaling.rs Adds scaling support for DucModelElement.
packages/ducpdf/src/duc2pdf/src/lib.rs Includes DucModelElement in bounding box calculation.
packages/ducpdf/src/duc2pdf/src/builder.rs Removes BlockManager from builder state and streaming calls; updates element-base matching.
packages/ducjs/src/types/index.ts Adds "doc"/"pdf" to ToolType and reorders exports/import types.
Comments suppressed due to low confidence (2)

packages/ducpdf/src/duc2pdf/src/streaming/stream_resources.rs:63

  • This file still carries BlockManager state (block_manager: Option<BlockManager>) and an initialize(..., block_manager: BlockManager, ...) parameter, but block_manager is never used anywhere outside initialization. Since this PR is removing BlockManager from PDF generation, consider removing the field/parameter (and the use hipdf::blocks::BlockManager import) here as well to avoid dead code and keep the API aligned with the new design.

    /// PDF embedder
    pdf_embedder: Option<PdfEmbedder>,
    /// Block manager for reusable content
    block_manager: Option<BlockManager>,

packages/ducpdf/src/duc2pdf/src/streaming/stream_resources.rs:226

  • process_pdf_file stores ResourceInfo { object_id: None } for PDFs, but stream_pdf_resource later requires object_id: Some(...) and otherwise returns a "no object ID" comment. As a result, PDF resources processed here cannot be streamed via ResourceStreamer. Either store the necessary XObject name/object id when embedding, or change stream_pdf_resource to use PdfEmbedder/embed_id (and update ResourceInfo) so streaming PDFs works end-to-end.
        Ok(ResourceInfo {
            id: file_entry.key.clone(),
            resource_type: ResourceType::Pdf,
            object_id: None, // PDF embedder handles object IDs internally
            width: Some(width),

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 332 to 336
let is_plot_mode = matches!(self.current_mode, StreamMode::Plot);
let (bounds_x, bounds_y, bounds_width, bounds_height) = bounds;
let bounds_max_x = bounds_x + bounds_width;
let bounds_max_y = bounds_y + bounds_height;
let (scroll_x, scroll_y) = if let Some(state) = local_state {
(state.scroll_x, state.scroll_y)
} else {
(0.0, 0.0)
};
let (_bounds_x, _bounds_y, _bounds_width, _bounds_height) = bounds;



Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stream_elements_within_bounds no longer uses bounds (it is destructured into _bounds_*) and the earlier scroll/bounds calculations were removed. This effectively disables bounds-based culling in crop mode and can render elements outside the requested region while increasing work. Either reintroduce bounds-intersection filtering (with scroll offset) or rename/adjust the API/comment so callers don’t assume bounds are enforced.

Copilot uses AI. Check for mistakes.
Comment on lines +595 to +597
DucElementEnum::DucModelElement(_) => {
vec![Operation::new("% DucModelElement - WIP", vec![])]
}
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new DucModelElement branch currently only emits a "% ... - WIP" comment operation, so there is still no actual rendering support. If the PR intent is to "add DucModelElement support", either implement streaming for this element type or adjust the PR description/title to reflect that it is only scaffolding/placeholder handling for now.

Copilot uses AI. Check for mistakes.
Comment on lines 154 to 156
// Get SVG dimensions from the converted XObject
let (width, height) = self.get_svg_dimensions(file_entry);
let (width, height) = (100.0, 100.0);

Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment says "Get SVG dimensions from the converted XObject", but the code now hard-codes (100.0, 100.0). Either compute real dimensions (e.g., parse the SVG viewBox/width/height or inspect the produced XObject bbox) or update/remove the comment so callers don’t assume these values are meaningful.

Copilot uses AI. Check for mistakes.
fill_from_stroke: false,
apply_stroke_properties: false,
},
&DucElementEnum::DucModelElement(_) => todo!(),
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

determine_style_profile uses todo!() for DucModelElement, but stream_element_with_resources calls apply_styles for all non-PDF elements (including DucModelElement). This will panic at runtime as soon as a model element is encountered. Add a real StyleProfile mapping for DucModelElement (likely similar to other WIP/ignored elements) or explicitly skip style application for model elements until rendering is implemented.

Suggested change
&DucElementEnum::DucModelElement(_) => todo!(),
&DucElementEnum::DucModelElement(_) => StyleProfile {
use_background_fill: false,
fill_from_stroke: false,
apply_stroke_properties: false,
},

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Contributor

github-actions bot commented Feb 9, 2026

🎉 This PR is included in version 2.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions
Copy link
Contributor

github-actions bot commented Feb 9, 2026

🎉 This PR is included in version 3.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions
Copy link
Contributor

github-actions bot commented Feb 9, 2026

🎉 This PR is included in version 2.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant