feat: add PDF export (cpdf) and PDF import (ipdf) commands#218
Open
4ni1ak wants to merge 5 commits intomlightcad:mainfrom
Open
feat: add PDF export (cpdf) and PDF import (ipdf) commands#2184ni1ak wants to merge 5 commits intomlightcad:mainfrom
4ni1ak wants to merge 5 commits intomlightcad:mainfrom
Conversation
- Add AcApPdfConvertor: reuses AcSvgRenderer pipeline, converts the resulting SVG to a vector PDF using jsPDF and svg2pdf.js - Add AcApConvertToPdfCmd: thin command wrapper, registered as 'cpdf' - Register 'cpdf' command in AcApDocManager.registerCommands() - Add 'Export to PDF' menu item in MlMainMenu.vue - Add exportPdf i18n key to en/zh locale files
- Add AcApPdfImportConvertor: loads PDF with pdfjs-dist, walks the operator list (moveTo/lineTo/curveTo/closePath), converts path segments to AcDbPolyline / AcDbLine entities, appends to model space - Cubic bezier curves approximated as 8-segment polylines - Coordinates scaled from PDF points to mm (1pt = 25.4/72 mm) - Y-axis flipped to match CAD coordinate convention - Add AcApImportPdfCmd: thin command wrapper, registered as 'ipdf' - Register 'ipdf' command in AcApDocManager.registerCommands() - Add 'Import PDF' menu item in MlMainMenu.vue - Add importPdf i18n key to en/zh locale files
Contributor
Author
|
Conflict resolved. The two TypeScript build errors ( |
Owner
|
@4ni1ak Is it possible to implement it as one plugin so that users can use it on demand because currently thei size of cad-viewer bundle isn't small any more. So I created plugin mechnisam to handle it. You can find the related code in folder 'packages\cad-simple-viewer\src\plugin'. |
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.
Summary
Adds two new PDF-related commands:
1.
cpdf— Export to PDF (vector)Reuses the existing
AcSvgRendererpipeline, converts the SVG output to a vector PDF using jsPDF + svg2pdf.js, and downloadsdrawing.pdf.2.
ipdf— Import PDFUses pdfjs-dist to extract vector geometry from the first PDF page and append it to the current document's model space:
moveTo / lineTo→AcDbLine/AcDbPolylineNew files
AcApPdfConvertor.tsAcApConvertToPdfCmd.tscpdf)AcApPdfImportConvertor.tsAcApImportPdfCmd.tsipdf)Changed files
AcApDocManager.ts— registerscpdfandipdfcommandscommand/index.ts— exports new classesMlMainMenu.vue— "Export to PDF" and "Import PDF" menu itemslocale/en/main.ts,locale/zh/main.ts— i18n keysTest plan
pnpm build— all packages compile without errorsdrawing.pdfdownloads with vector geometrycpdf/ipdfin command bar — same results