Download

Online

Gallery

Blog

  Index  | Recent Threads  | List Attachments  | Search
 Welcome Guest  |  Register  |  Login
Login Name  Password
 

Sweet Home 3D Forum



No member browsing this thread
Thread Status: Active
Total posts in this thread: 10
[ Jump to Last Post ]
Post new Thread
Author
Previous Thread This topic has been viewed 308 times and has 9 replies
AlexDeveloper
Newbie




Joined: Mar 18, 2024
Post Count: 10
Status: Offline
Reply to this Post  Reply with Quote 
smile Generate PDF file.

Hello, I am appealing to this developer audience with a problem that I have faced.

I have made some changes to the drawing wall. Changes are labeled on the center of each wall and show the length of the wall (see video - link ). My problem is that when I want to export the plan in a PDF file white labels that are on the center of each wall do not export in PDF and I see just black walls without white labels (see vide - link).

But when I use a plugin "Export plan to PNG" everything works correctly (see screenshot - link ).

here is a code changes in the method paintWalls - link
brief code:

for (Wall var18 : var13) {
if (home.wallType.contains(var18.getModeCreationName())) {

float var19 = var18.getStartPointToEndPointDistance();
String var20 = this.preferences.getLengthUnit().getFormat().format(var19);
AttributedString var21 = new AttributedString(var20);
var21.addAttribute(TextAttribute.BACKGROUND, Color.WHITE);
var21.addAttribute(TextAttribute.FONT, var16);
AffineTransform var22 = g2D.getTransform();
double var23 = Math.atan2((double) (var18.getYEnd() - var18.getYStart()), (double) (var18.getXEnd() - var18.getXStart()));
boolean var25 = var23 < -1.5707963267948966 || var23 > 1.5707963267948966;
if (var25) {
g2D.translate((double) var18.getXEnd(), (double) var18.getYEnd());
g2D.rotate(Math.PI + var23);
} else {
g2D.translate((double) var18.getXStart(), (double) var18.getYStart());
g2D.rotate(var23);
}

FontMetrics var26 = this.getFontMetrics(var16, var29);
Rectangle2D var27 = var26.getStringBounds(var20, g2D);
g2D.translate((double) ((var19 - (float) var27.getWidth()) / 2.0F), (double) ((float) var27.getHeight() / 2.0F));
g2D.drawString(var21.getIterator(), 0, 0);
g2D.setTransform(var22);
}
}


Thank you very much for your help!! smile smile smile smile
[Apr 11, 2024, 11:55:28 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
sjb007
Advanced Member




Joined: May 18, 2021
Post Count: 219
Status: Offline
Reply to this Post  Reply with Quote 
Re: Generate PDF file.

I'm curious, does exporting to SVG correctly show your wall labels?

There's a PaintMode (PAINT, PRINT, CLIPBOARD, EXPORT) which is selecting different bits of code in the PlanComponent.java file depending on if you are painting to screen, printing, exporting to SVG, or copying to clipboard. The answer might lie in that code.

(Not a dev, just a tinkerer.)
[Apr 12, 2024, 3:47:21 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
sjb007
Advanced Member




Joined: May 18, 2021
Post Count: 219
Status: Offline
Reply to this Post  Reply with Quote 
Re: Generate PDF file.

Oh, to be clear...

It looks like PDF is using the PRINT mode, and SVG uses the EXPORT mode. Obviously PAINT is for rendering to screen.
[Apr 12, 2024, 3:48:57 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
upiazzolla@hotmail.com
Member
Member's Avatar

Italy
Joined: Apr 12, 2019
Post Count: 54
Status: Offline
Reply to this Post  Reply with Quote 
Re: Generate PDF file.

Good morning
I read your trend's email.
I am not a programmer, but I can say that I fully agree with Sib007, given that PDFs (Portable Document Files) are by their constructive and historical characteristic an evolution of the Postscript PRINT language (also from Adobe), both logical and any autonomous source of Building a PDF file actually uses PRINT instructions
[Apr 12, 2024, 11:08:38 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
AlexDeveloper
Newbie




Joined: Mar 18, 2024
Post Count: 10
Status: Offline
Reply to this Post  Reply with Quote 
Re: Generate PDF file.

Exporting to SVG works correctly - see link
[Apr 12, 2024, 12:17:39 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
AlexDeveloper
Newbie




Joined: Mar 18, 2024
Post Count: 10
Status: Offline
Reply to this Post  Reply with Quote 
Re: Generate PDF file.

But in PAINT mode still do not draw white labels on the walls((
[Apr 12, 2024, 12:54:56 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Daniels118
Advanced Member
Member's Avatar

Italy
Joined: Nov 17, 2021
Post Count: 408
Status: Offline
Reply to this Post  Reply with Quote 
Re: Generate PDF file.

Are you REALLY sure that labels aren't painted? It could be that in PDF they are drawn by default using transparent background, so the text cannot be seen. Try to select the text in the exported PDF, if the labels are there, then you should see the text highlighted.
If this is so, then you could simply set the background color; if background color isn't an available feature, just draw a rectangle before drawing the text.

Just courious: why in the world are these variables called this way?
Have you used a decompiler to get the source code? You should know that this is an open source software, so you can get the original sources.
[Apr 12, 2024, 3:51:41 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
AlexDeveloper
Newbie




Joined: Mar 18, 2024
Post Count: 10
Status: Offline
Reply to this Post  Reply with Quote 
Re: Generate PDF file.

Thank you for your answer!

Yes, you are right) text on the wall exists but they are under a black layer but without a little white background as on the sweethome3d editor.

check screenshot - link

but I think I need a programmer who has a lot of experience contributing to this application and maybe can make me a point about why it is as is.

what bout the code it is from my friend jar and I am gonna rename the variables. I am developing a very useful plugin for myself maybe for the public.
[Apr 12, 2024, 4:33:10 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
AlexDeveloper
Newbie




Joined: Mar 18, 2024
Post Count: 10
Status: Offline
Reply to this Post  Reply with Quote 
sad Re: Generate PDF file.

Someone can help me? sad
[Apr 14, 2024, 9:07:37 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Puybaret
Expert
Member's Avatar

France
Joined: Nov 7, 2005
Post Count: 9185
Status: Offline
Reply to this Post  Reply with Quote 
Re: Generate PDF file.

First thing, if you want some help, you have to help programmers understanding your code too. Naming every variable varsomething is really troublesome and in the long term, it won't help your code maintenance. Some comments could be welcomed too, at least to show where you made some modifications.

Then, in your code:
if (home.wallType.contains(var18.getModeCreationName())) {
wallType and getModeCreationName are new field and method you introduced in your derived version. Are you sure that this condition is fulfilled? Did you use a debugger to check how it works?
Did you try to print, instead of printing to PDF? Then, try to print through a PDF printer driver?
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D developer
[Apr 15, 2024, 11:23:44 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
[ Jump to Last Post ]
Show Printable Version of Thread  Post new Thread

    Get Sweet Home 3D at SourceForge.net. Fast, secure and Free Open Source software downloads
   
© Copyright 2006-2024 eTeks - All rights reserved