Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(WIP) Make PDF Print/Export work without having to use Print Preview first #1188

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

martinvanzijl
Copy link
Contributor

Fixes #751.

Exporting/Printing PDF files now works without having to use Print Preview first. Tested on Ubuntu 18.04.

Export PDF file works without having to use Print Preview first.
@lordofbikes
Copy link
Member

Many thanks for this contribution!
Sadly, this is not the complete solution. PDF export would be limited to fit to page.
If one would generate a PDF with specified scale, via print preview, this will not work with this fix anymore.

@martinvanzijl martinvanzijl changed the title Make PDF Print/Export work without having to use Print Preview first (WIP) Make PDF Print/Export work without having to use Print Preview first May 30, 2020
@martinvanzijl
Copy link
Contributor Author

@lordofbikes Thanks for your comment. I guess I should have tested more thoroughly!

I tried this since the call to graphic->fitToPage(); was the only difference I could see in the code for "print preview" vs. "print/export".

Anyway, I think I see the real problem. If you just use "print/export" without doing a print preview first, it will export the area around the center of the diagram. If there are no elements near the center, this exports an empty page.

I attached a demo below to explain this (zipped OGV), done with master branch without this fix:

export-problem-demo.zip

At least with print preview, it does a "fit to page" at the start, which means the diagram's elements will be included on page, regardless of whether they are near the center or not.

@martinvanzijl
Copy link
Contributor Author

As for how to fix the issue properly, I can suggest either:

  1. Use fit-to-page if the user has not done Print Preview yet. If the user has done Print Preview before, use the settings from there instead. OR
  2. Always show print preview before printing/exporting.

Anyway, feel free to close this branch.

@lordofbikes
Copy link
Member

Don't worry, this is a real issue indeed and your efforts are more than welcome.
I tend to your solution 1.
Then inexperienced users will have an output at least and often a fit to page print is enough.
Maybe a little hint message (about print preview) in the command history can help when fitToPage() was applied.
I think a missing drawing area is the cause for this issue. In slotFilePrint() we have access to RS_Graphic* graphic, I assume there is the drawing area and insertion point set from print preview.
So I think the solution is to check if graphic contains a valid area and if not, call fitToPage().

If you can have a look at this, you're welcome. Then simply push modifications to this branch.
But if you can't, no problem, I'll keep this open until someone has battled this issue down.

@dellus
Copy link

dellus commented May 30, 2020

I have long since been of the opinion it would be better to always run printing and pdf/bitmap export via PrintPreview. I have recently discovered that QCAD does it this way, kind of. Maybe worth to have a look on it.
qcadppv

@fa201
Copy link

fa201 commented May 31, 2020

I agree with @dellus. The process would be smoother and easier for newcomers.
We could have one print menu in which we set up the print/export and then print/export.

@lordofbikes lordofbikes added PR xsmall pull request, very small diff size PR improvement pull request, changing an existing feature or behavior PR next release pull request, to be considered for next release labels Apr 27, 2022
@Salamek
Copy link

Salamek commented Feb 1, 2024

Still happening to me on 2.2.0... on Archlinux... i was getting white empty page when using File -> Export -> Export as PDF, when i did the same from print preview it worked ok...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR improvement pull request, changing an existing feature or behavior PR next release pull request, to be considered for next release PR xsmall pull request, very small diff size
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Printing into pdf produces empty page
5 participants