View Issue Details

IDProjectCategoryView StatusLast Update
0002972TechDrawBugpublic2017-05-10 16:08
Reportersankey Assigned Towandererfan  
Status closedResolutionfixed 
PlatformLinuxOSUbuntuOS Version16.04
Product Version0.17 
Fixed in Version0.17 
Summary0002972: TechDraw PDF export from Python can only make PDFs of a Page in foreground
DescriptionWith Python it is only possible to export TechDraw Pages which are open and in the foreground.

Steps To ReproduceExperiment 1:

1. Create two TechDraw pages and draw things in them to identify them.
2. View the first page ("Page"). It should be in the foreground.
3. Open the python console and try to export the second page ("Page001") as PDF:

obj = FreeCAD.ActiveDocument.getObject("Page001")
FreeCADGui.export([obj], u"/tmp/Page001.pdf")
4. Observe that the exported PDF is in fact a rendering of the first page ("Page")

Experiment 2:

1. Continue from the same document as Experiment 1.
2. Close all TechDraw pages.
3. Try again to export "Page001" as PDF.
4. Observe that the exported PDF is completely blank!
Additional InformationOS: Ubuntu 16.04.1 LTS
Word size of OS: 32-bit
Word size of FreeCAD: 32-bit
Version: 0.17.10476 (Git)
Build type: None
Branch: master
Hash: b6150097e9cf4d7b0f5ad71f2f8750f2e7aac0d9
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.1.0
FreeCAD Information


related to 0002971 closedwandererfan hiding foreground TechDraw page from Python causes segfault 
child of 0003002 closedwandererfan TechDraw - Update python bindings 



2017-04-28 02:18

administrator   ~0008790

Last edited: 2017-04-28 21:49

View 2 revisions

Forum thread:

Edit: @sgrogan mentioned that this ticket actually evolved out of this thread (but OP didn't mention it):


2017-04-28 14:38

administrator   ~0008800

Last edited: 2017-04-28 14:39

View 2 revisions

obj = FreeCAD.ActiveDocument.getObject("Page001")
FreeCADGui.export([obj], u"/tmp/Page001.pdf")

[mono]FreeCADGui.export[/mono] is part of the core system and thus doesn't know anything about objects of extension modules. This function gets the object to check which document it is part of and then simply uses the active view of this document and export that as pdf. See

So to achieve what you want there are some alternatives how to realize it:
* add a function to the Py interface of TechDrawGui that accepts a [mono]DrawPage[/mono] object and path name. Inside this function can access the correct mdi page via the view provider and export the content as pdf
* another way could be to implement a specialized Python wrapper for the view provider that offers the needed interface for export[/quote]

Related Changesets

FreeCAD: master 5a0f53d7

2017-05-09 00:43:39


Committer: wmayer Details Diff
Fix 0002972 Export Pdf Page Not in Foreground

exposes TechDrawGui.exportPageAsPdf(page,file)
also adds TechDrawGui.exportPageAsSvg(page,file)
Affected Issues
mod - src/Mod/TechDraw/Gui/AppTechDrawGui.cpp Diff File
mod - src/Mod/TechDraw/Gui/AppTechDrawGuiPy.cpp Diff File
mod - src/Mod/TechDraw/Gui/MDIViewPage.cpp Diff File
mod - src/Mod/TechDraw/Gui/MDIViewPage.h Diff File
mod - src/Mod/TechDraw/Gui/ViewProviderPage.h Diff File

Issue History

Date Modified Username Field Change
2017-03-18 21:28 sankey New Issue
2017-03-20 12:32 Kunda1 Project FreeCAD => TechDraw
2017-03-20 12:33 Kunda1 Relationship added related to 0002971
2017-04-28 02:18 Kunda1 Tag Attached: python
2017-04-28 02:18 Kunda1 Note Added: 0008790
2017-04-28 14:38 Kunda1 Note Added: 0008800
2017-04-28 14:39 Kunda1 Note Edited: 0008800 View Revisions
2017-04-28 21:49 Kunda1 Note Edited: 0008790 View Revisions
2017-04-29 11:48 Kunda1 Status new => confirmed
2017-04-29 15:27 Kunda1 Relationship added child of 0003002
2017-05-10 16:04 wmayer Changeset attached => FreeCAD master 5a0f53d7
2017-05-10 16:08 wmayer Assigned To => wandererfan
2017-05-10 16:08 wmayer Status confirmed => closed
2017-05-10 16:08 wmayer Resolution open => fixed
2017-05-10 16:08 wmayer Fixed in Version => 0.17