xanderdin / LibreCAD_dxf2pdf_standalone

Standalone extracted version of LibreCAD's dxf2pdf tool that could be run without running X server.
GNU General Public License v2.0
11 stars 2 forks source link

[Question]Is this awesome tool cross-platform? #5

Closed liesauer closed 4 years ago

liesauer commented 4 years ago

i am not very familiar with cmake stuff, but i realize that the build script is a shell script, so it is definitely linux or unix supported, right? but is this windows supported? do i need a cross-build? i use imac for my works and our server is windows but it will be shifted to linux in the future, so getting three platforms supported is very important for us. In the end, thanks for creating a such amazing tool, and it is very useful for us.

liesauer commented 4 years ago

Update: boost、qt5 are required in macos

brew install boost
brew install qt5
liesauer commented 4 years ago

is this has limitation or some compatible issue? like dxf version or something? i already tried 2010 and 2007 versions of dxf. i tried a couple of my dxf files and all failed.

either output a tiny blank(white) pdf or a huge blank(white) pdf. Even if only draw a very simple drawing with some lines.

image

xanderdin commented 4 years ago

Currently, I have no Windows at my disposition, so I'm not 100% sure... Git for Windows has Bash so you can try running the script with it (https://gitforwindows.org/). The code itself should build OK, but as far as I remember, there were some issues with console output on Windows and with running outside Bash environment provided by Git for Windows (e.g.: cmd.exe, PowerShell). Nevertheless, PDF conversion itself worked fine.

As for blank output, this tool uses LibreCAD's code for all processing. If you can open and print your DXF files to PDF in LibreCAD then this tool should produce the same results also. If LibreCAD fails then this tool definitely would fail too.

liesauer commented 4 years ago

ok, i downloaded LibreCAD and retried. it seems a LibreCAD's problem.

liesauer commented 4 years ago

@xanderdin i exported to a pdf successfuly with LibreCAD by following this steps. but i still get blank in this tool. it seems that it need to set and read some settings. how can i do the same thing as those steps?

xanderdin commented 4 years ago

As far as I remember, those settings are kept in DXF file itself, so try saving your file in LibreCAD first after following mentioned steps. Entering preview mode is also required because it modifies some settings and they should be also saved.

liesauer commented 4 years ago

same dxf. success in LibreCAD but fail in dxf2pdf.

liesauer commented 4 years ago

i try to rebuild dxf2pdf with command ./prepare.sh e469c5e8d6db3297330161f6e95fd79cac9e780d which is written in README. and found there is a fail patch. image

***************
*** 102,111 ****
          return true;
      }

-   QSettings s(companyKey, appKey);
-     // RVT_PORT not supported anymore s.insertSearchPath(QSettings::Windows, companyKey);

-     s.setValue(QString("%1%2").arg(group).arg(key), value);
    cache[key]=value;

      return true;
--- 102,113 ----
          return true;
      }

+     // xanderdin: dxf2pdf should not write any settings to permanent storage

+   // QSettings s(companyKey, appKey);
+     // // RVT_PORT not supported anymore s.insertSearchPath(QSettings::Windows, companyKey);
+ 
+     // s.setValue(QString("%1%2").arg(group).arg(key), value);
    cache[key]=value;

      return true;

is this related?

xanderdin commented 4 years ago

No, this is unrelated. In README it is just an example. Because this project is a set of patches, it may or may not work against a certain LibreCAD's commit. It depends on how different are original files in a certain LibreCAD's commit from those which are the basis for the patch. The commit hash which is set in prepare.sh script is known to work, others may not.

Also I played with your test.dxf file. And here what I got.

dxf2pdf test.dxf

The line above, as you said, produces a PDF with no visible content.

2.

dxf2pdf -a test.dxf

This produces a PDF file where drawing is fully visible (-a option means fit on page), but the size of the PDF file is huge (57Mb).

3.

dxf2pdf -s 0.3 -p 148x105 -c test.dxf

This also produces a PDF file where drawing is fully visible (paper size is set to A6 landscape, scale 1:30, centered on page), but the size of the PDF file is still pretty big - 13Mb.

You can play further with command line options to achieve desired results with your file if you want. But there's another way. The best result is achieved when first, as I suggested earlier, the file is opened in LibreCAD and then re-saved. The complete steps are:

  1. Open your test.dxf file in LibreCAD.
  2. Open Drawing Preferences (menu Options->Current Drawing Preferences).
  3. Set paper format to A4 (or whatever you want), press [Ok] button.
  4. Open print preview (menu File->Print Preview).
  5. In print preview, set whatever you need (scale, center on page, etc.).
  6. Save file.

After those steps, running

dxf2pdf test.dxf

produces fine and expected result and the file size of the PDF file is also just 40Kb.

Hope it helps.

fa201 commented 4 years ago

Did you check the documentation : https://librecad.readthedocs.io/en/latest/appx/build.html#building-on-windows If you seek support then LibreCAD forum should be more appropriate : https://forum.librecad.org

liesauer commented 4 years ago

@xanderdin i have exported to pdf successfully, thanks! and thanks @fa201 too.