The issues with the command line tool dwg2pdf

If you are having problems with QCAD, post here. Please report bugs through our Bug Tracker instead.

Always attach your original DXF or DWG file and mentions your QCAD version and the platform you are on.

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files and screenshots.

Post one question per topic.

Post Reply
hik-IT
Junior Member
Posts: 20
Joined: Wed Jun 11, 2025 2:33 am

The issues with the command line tool dwg2pdf

Post by hik-IT » Tue Jul 15, 2025 10:08 am

the issues is :When converting DWG files to PDF, some hatch patterns and text elements are missing or distorted.
How can I resolve this issue?
The command used was: ./dwg2pdf -platform offscreen -auto-fit -auto-orientation -center -max-lineweight=0.005 -flat -f -o 1.pdf A.dwg.
Environment
CentOs7
Qcad 3.23.3 pro
Qcad 3.23.3 server
Attachments
铁桥新家园三期总图_t3-管线布点图.dwg
(379.27 KiB) Downloaded 126 times
2.pdf
(432.22 KiB) Downloaded 633 times

CVH
Premier Member
Posts: 4920
Joined: Wed Sep 27, 2017 4:17 pm

Re: The issues with the command line tool dwg2pdf

Post by CVH » Tue Jul 15, 2025 11:18 am

Hi,

At least 24 notifications: "Unsupported XData type NOT imported: 1005"

There are not many Hatch entities in the drawing.
I found 2 Hatches in the 'HUAYI' logo in the title box below but that is not rendered at all.

Several missing text or other art in the PDF is set to white in the drawing.
Perhaps preventing 'White on White and Black on Black' is an option: See Application Preferences.

There is no guaranty on how long Text entities are when rendered in QCAD.

A4 PDF, native size in mm ... Your maximum lineweight is set to 0.005 mm or 5 micron (20 times smaller than a human hair).
Typically we set a minimum lineweight to avoid that things drawn in 0.00mm or 0.05mm are missing or hardly visible.
Several things are drawn in weight 'Default': Refer to Application Preferences what weight is configured for the default weight.
Remember that a lineWeight is not scaled.


Seems OK when exported with the GUI: Print Preview, Auto scale, export to PDF.
2rev.pdf
(906.46 KiB) Downloaded 618 times

Regards,
CVH

hik-IT
Junior Member
Posts: 20
Joined: Wed Jun 11, 2025 2:33 am

Re: The issues with the command line tool dwg2pdf

Post by hik-IT » Wed Jul 16, 2025 4:20 am

How can I resolve this issue by the command line tool
like: ./dwg2pdf -platform offscreen -auto-fit -auto-orientation -center -max-lineweight=0.005 -flat -f -o 1.pdf A.dwg.

CVH
Premier Member
Posts: 4920
Joined: Wed Sep 27, 2017 4:17 pm

Re: The issues with the command line tool dwg2pdf

Post by CVH » Wed Jul 16, 2025 6:03 am

Not everything is fixable via the command line.
Extended data is not supported, a white pen on paper doesn't show, near white will be hardly visible ...
... Lines much thinner than a hair are almost invisible ...

In any case, the drawing must be suitable for printing.
That is hardly the case in your other recent post.

dwg2pdf is in essence a Print implementation.
It has no switch to correct colors, like available for dwg2bmp.
I suspect that the standard color correction by Application Preference is used.

Verify in QCAD with GUI: Menu Edit .. Application Preferences .. Graphics View .. Appearance .. Color Adjustment
Enable "Prevent white on white / black on black display".
Not disabled for printing.
That may not fix all colors as there are near white entities and/or layers.
Perhaps increasing the lightness threshold may be an option.

My "Default" lineweight by preference is not necessarily yours because that is user defined.
Verify in QCAD with GUI: Menu Edit .. Application Preferences .. Graphics View .. Appearance .. Linetypes and Lineweights
A reasonable "Default Lineweight" would be in order, for example 0.25mm (ISO)

Avoid the use of 0.00mm here what in essence means 'nothing at all' but visible as 1pixel wide in any GUI zoom state.
Fine for construction or auxiliary lines or for other special applications.

Lines in the "Default" lineweight will then always be 0.25mm wide on paper.

Set at least a minimal lineweight, for example -min-lineweight=0.05
Set a reasonable maximal lineweight, for example -max-lineweight=1 instead of 5 microns

Regards,
CVH

User avatar
andrew
Site Admin
Posts: 8774
Joined: Fri Mar 30, 2007 6:07 am

Re: The issues with the command line tool dwg2pdf

Post by andrew » Wed Jul 16, 2025 8:04 am

hik-IT: You can use the -color-correction command line switch to make sure that white objects / layers are exported in black.

I'm getting decent results with:

Code: Select all

./dwg2pdf -platform offscreen -auto-fit -auto-orientation -color-correction -center -min-lineweight=0.1 -max-lineweight=0.1 -flat -f -o output.pdf input.dwg
Note that -color-correction was added to dwg2pdf in the latest release QCAD 3.32.3.

hik-IT
Junior Member
Posts: 20
Joined: Wed Jun 11, 2025 2:33 am

Re: The issues with the command line tool dwg2pdf

Post by hik-IT » Wed Jul 16, 2025 8:55 am

Thank you for your reply.
I have another issues: some lines in the DWG file are not rendered when converted to PDF using DWG2PDF. What could be the reason for this?
How can I resolve this issue

Environment
CentOs7
Qcad 3.32.3 pro
Qcad 3.32.3 server
Attachments
Image20250716155118791.png
Image20250716155118791.png (106.09 KiB) Viewed 16134 times
1.pdf
(812.46 KiB) Downloaded 651 times

CVH
Premier Member
Posts: 4920
Joined: Wed Sep 27, 2017 4:17 pm

Re: The issues with the command line tool dwg2pdf

Post by CVH » Wed Jul 16, 2025 5:24 pm

andrew wrote:
Wed Jul 16, 2025 8:04 am
Note that -color-correction was added to dwg2pdf in the latest release QCAD 3.32.3.
I didn't intend to give faulty info.
Even this morning there were but 5 hits for the term 'corr' on the Command Line Tools page, 4 pointing to the word 'correction' ...
... Now there are 7 hits meaning that 2 were added meanwhile. :wink:
hik-IT wrote:
Wed Jul 16, 2025 8:55 am
some lines in the DWG file are not rendered when converted to PDF using DWG2PDF.
You probably refer to those in the red rectangle ...
... Otherwise please post some handles of the missing lines in the PDF.

In the red rectangle we discover a Block Reference based on Block 'A$C0F44124B'
I can not select that with the cursor, highlighted I can double click it what edits the intended block.

Back in Model_Space the Selection Filter can not select it but TA selects everything.
My block label tool tells me it has handle 0x16db ... TH won't select anything but reports that object 3360 is selected.

We can select all (TA), subtract the mystery Block Reference on referenced Block name with the Selection Filter.
After inverting the selection (TI) no selection remains ...

But it get a bit more weirder ...
Select all by dragging a box with the cursor > 996 entities, in the dropdown it list 7 Block References.
Select all by TA > 1133 entities (+137) > 144 Block References (+137).

TBC

Regards,
CVH

User avatar
andrew
Site Admin
Posts: 8774
Joined: Fri Mar 30, 2007 6:07 am

Re: The issues with the command line tool dwg2pdf

Post by andrew » Thu Jul 17, 2025 10:02 am

hik-IT wrote:
Wed Jul 16, 2025 8:55 am
I have another issues: some lines in the DWG file are not rendered when converted to PDF using DWG2PDF. What could be the reason for this?
I can confirm that the reference to this anonymous block is not loaded for unknown reasons. I've created a bug report at:
https://www.qcad.org/bugtracker/index.p ... sk_id=2683

CVH
Premier Member
Posts: 4920
Joined: Wed Sep 27, 2017 4:17 pm

Re: The issues with the command line tool dwg2pdf

Post by CVH » Thu Jul 17, 2025 11:07 am

The above and probably the missing lines in the export are related to hidden layers.

The content of Block 'A$C0F44124B' are 94 entities on layer 'PUB_TITLE' itself not hidden.
The Block Reference entity '0x16db' lives on layer 'PUB_DIM' what is hidden.

Still, the Block Reference is visible in Model_View and in Print Preview mode.
Also highlighted when pointing near it but NOT selectable with the cursor by clicking or with a box selection, selectable by TA.


I was convinced that the Block entity layers AND the Block Reference layer had to visible so that content was visible ...
If we (re)read all topics filtered on a combination of 'Visible'/'Visibility' and 'Block'/'Blocks' we might get conflicting information.

In the QCAD FAQ (8 aug 2018) is stated that:
  • Turning off the layer of the Block Reference will make the whole block reference invisible.
Conflicting with a reply by Andrew (30 nov 2017):
  • If a layer is off, block references are still shown but these are not shown when the layer is frozen.
The first is confirmed in this earlier reply by Andrew (8 mar 2016):
  • If an entity is part of a block, the entity also becomes invisible if the layer the block reference is on is hidden.
The second is then confirmed in this reply by Andrew (11 jan 2022):
  • When turning off the block content layer, the block reference on another layer is not hidden.

The context and several preferences may have an influence:
- Different for Layer 0 in best compatibility mode
- Including the frozen column or not and for the latter case not opting for Off = Frozen


Exporting to PDF using the GUI worked out.
Attempted a life test exporting your DWG to PDF with the command line instruction.

Using a trial of QCAD 3.32.3 was not an option: FS#2684
Reverted to QCAD3.32.1 and I don't see any difference with the GUI export.
The Block in question is rendered fine in PDF although Andrew says otherwise.
andrew wrote:
Thu Jul 17, 2025 10:02 am
I can confirm that the reference to this anonymous block is not loaded for unknown reasons.

hik-IT-test.pdf
(757.95 KiB) Downloaded 638 times

For completeness the debug output:

Code: Select all

E:\CNC\QCAD\QCAD_32.1>dwg2pdf -platform offscreen -auto-fit -auto-orientation -color-correction -center -min-lineweight=0.1 -max-lineweight=0.1 -flat -f -o hik-IT-test.pdf hik-IT-test.dwg
QCAD version  3.32.1
11:50:34: Debug:    loading plugins...
11:50:34: Debug:    RPolygonPlugin::init
11:50:34: Debug:    RProScriptsPlugin::init: trial


You are using a trial version of QCAD Professional.
If you would like to use this software productively,
please purchase the full version for a small license fee from our
Online Shop at:
https://qcad.org/shop
Thank you for trying this add-on!

Your script will start in 15 seconds...


11:50:49: Debug:    RProxiesPlugin::init: trial
11:50:50: Debug:    RTracePlugin::init: trial
11:50:50: Debug:    RDwgPlugin::init: trial
11:50:50: Debug:    loading static plugins...
11:50:50: Debug:    addObject: block: "*Model_Space"
11:50:50: Debug:    addObject: block: "*Paper_Space"
11:50:50: Debug:    addObject: block: "*Model_Space"
11:50:50: Debug:    addObject: block: "*Paper_Space"
Warning:  cannot assign original handle to object "0x7"
Warning:  collision with object of type: 4
Warning:  new handle "0x194e"
Warning:  cannot assign original handle to object "0x27"
Warning:  collision with object of type: 2
Warning:  new handle "0x194f"
Warning:  cannot assign original handle to object "0x13"
Warning:  collision with object of type: 2
Warning:  new handle "0x1950"
Warning:  cannot assign original handle to object "0x2"
Warning:  collision with object of type: 2
Warning:  new handle "0x1951"
11:50:50: Debug:    addObject: block: "*MODEL_SPACE"
11:50:50: Debug:    addObject: block: "*PAPER_SPACE"
Warning:  cannot assign original handle to object "0x2c"
Warning:  collision with object of type: 2
Warning:  new handle "0x1952"
11:50:50: Debug:    addObject: block: "_OBLIQUE"
11:50:50: Debug:    addObject: block: "K2241"
11:50:50: Debug:    addObject: block: "831000"
11:50:50: Debug:    addObject: block: "953001"
11:50:50: Debug:    addObject: block: "941001"
11:50:50: Debug:    addObject: block: "931001"
11:50:50: Debug:    addObject: block: "671000"
11:50:50: Debug:    addObject: block: "914001"
11:50:50: Debug:    addObject: block: "K8410"
11:50:50: Debug:    addObject: block: "513100"
11:50:50: Debug:    addObject: block: "359000"
11:50:50: Debug:    addObject: block: "A$C66F272B3"
11:50:50: Debug:    addObject: block: "A$C7D633E49"
11:50:50: Debug:    addObject: block: "A$C55815D12"
Warning:  cannot assign original handle to object "0x1c"
Warning:  collision with object of type: 2
Warning:  new handle "0x1953"
11:50:50: Debug:    addObject: block: "_ArchTick"
11:50:50: Debug:    addObject: block: "HY08HQ"
11:50:50: Debug:    addObject: block: "HY2007Logo"
11:50:50: Debug:    addObject: block: "A$C5C5B78CA"
11:50:50: Debug:    addObject: block: "A$C0375763B"
11:50:50: Debug:    addObject: block: "A$C103A2850"
11:50:50: Debug:    addObject: block: "A$C79621BF0"
11:50:50: Debug:    addObject: block: "A$C239A1539"
11:50:50: Debug:    addObject: block: "A$C0AD5331F"
11:50:50: Debug:    addObject: block: "A$C5C680018"
11:50:50: Debug:    addObject: block: "A$C4431507C"
11:50:50: Debug:    addObject: block: "??k"
11:50:50: Debug:    addObject: block: "A$C62004A63"
11:50:50: Debug:    addObject: block: "A$C0F44124B"
11:50:50: Debug:    addObject: block: "_AXISO"
Warning:  cannot assign original handle to object "0x2e"
Warning:  collision with object of type: 2
Warning:  new handle "0x1954"
Warning:  cannot assign original handle to object "0x20"
Warning:  collision with object of type: 2
Warning:  new handle "0x1a4d"
Warning:  cannot assign original handle to object "0x12"
Warning:  collision with object of type: 2
Warning:  new handle "0x20c8"
Warning:  cannot assign original handle to object "0x30"
Warning:  collision with object of type: 2
Warning:  new handle "0x20c9"
Warning:  QFontDatabase: Cannot find font directory C:/Qt/Qt5.13.2/5.13.2/msvc2017/lib/fonts.
Note that Qt no longer ships fonts. Deploy some (from https://dejavu-fonts.github.io/ for example) or switch to fontconfig.
11:50:51: Debug:    entity on block  118 [ "HY2007Logo" ]  (not on current block 5 [ "*MODEL_SPACE" ])
11:50:51: Debug:    entity on block  108 [ "671000" ]  (not on current block 5 [ "*MODEL_SPACE" ])
11:50:51: Debug:    entity on block  114 [ "A$C7D633E49" ]  (not on current block 5 [ "*MODEL_SPACE" ])
11:50:51: Debug:    entity on block  118 [ "HY2007Logo" ]  (not on current block 5 [ "*MODEL_SPACE" ])
11:50:51: Debug:    entity on block  126 [ "A$C4431507C" ]  (not on current block 5 [ "*MODEL_SPACE" ])
11:50:51: Debug:    entity on block  126 [ "A$C4431507C" ]  (not on current block 5 [ "*MODEL_SPACE" ])
11:50:51: Debug:    entity on block  104 [ "831000" ]  (not on current block 5 [ "*MODEL_SPACE" ])
11:50:51: Debug:    entity on block  128 [ "A$C62004A63" ]  (not on current block 5 [ "*MODEL_SPACE" ])
11:50:51: Debug:    entity on block  129 [ "A$C0F44124B" ]  (not on current block 5 [ "*MODEL_SPACE" ])
Converting
  from: E:/CNC/QCAD/QCAD_32.1\hik-IT-test.dwg
  to  : E:/CNC/QCAD/QCAD_32.1\hik-IT-test.pdf
Warning:  RGraphicsViewImage::paintOverlay: no workers

E:\CNC\QCAD\QCAD_32.1>
Not all went well I presume but that is drawing file related.

Regards,
CVH

hik-IT
Junior Member
Posts: 20
Joined: Wed Jun 11, 2025 2:33 am

Re: The issues with the command line tool dwg2pdf

Post by hik-IT » Tue Jul 22, 2025 4:41 am

andrew wrote:
Thu Jul 17, 2025 10:02 am
hik-IT wrote:
Wed Jul 16, 2025 8:55 am
I have another issues: some lines in the DWG file are not rendered when converted to PDF using DWG2PDF. What could be the reason for this?
I can confirm that the reference to this anonymous block is not loaded for unknown reasons. I've created a bug report at:
https://www.qcad.org/bugtracker/index.p ... sk_id=2683
Was this issue fixed? :D :D :D :lol: :lol: :mrgreen:

CVH
Premier Member
Posts: 4920
Joined: Wed Sep 27, 2017 4:17 pm

Re: The issues with the command line tool dwg2pdf

Post by CVH » Tue Jul 22, 2025 5:40 am

CVH wrote:
Thu Jul 17, 2025 11:07 am
The Block in question is rendered fine in PDF although Andrew says otherwise.
I tested it on a Win7 machine with QCAD 3.32.1 (point 2 failed) typically Qt 5.13.2, perhaps OS or Qt related.
There are other problems with the drawing file, see debug output.
hik-IT wrote:
Tue Jul 22, 2025 4:41 am
Was this issue fixed?
No, probably not, otherwise FS#2683 would have the fixed status.
It is assigned to Andrew but that is automatically.

Regards,
CVH

Post Reply

Return to “QCAD Troubleshooting and Problems”