Mirrored text not displayed using Adobe Acrobat

Talk here about issues with one of the components hosted at wxCode, or suggest features for it.
Post Reply
rsb
I live to help wx-kind
I live to help wx-kind
Posts: 170
Joined: Fri May 29, 2015 7:26 pm

Mirrored text not displayed using Adobe Acrobat

Post by rsb »

Hello,

After creating a PDF file using the PDFDocument library from inside our application, we display the file using Adobe Acrobat.

The command we are using is:
"C:\Program Files\Adobe\Acrobat DC\Acrobat\Acrobat.exe" "B:\190313_test-3d-lib-test-pth-comps\pantheon\BOARD.pdf"

We have mirrored text in the design, but the text is missing or misplaced in Adobe.

Using a 3rd party application called BullZip PDF the mirrored text is correct.

I've attached the PDF file for each. Can you tell me what the problem is?

Thanks.
PDFDocument.7z
Directly From PDF Document library
(217.54 KiB) Downloaded 91 times
BullzipPDF.7z
From PDF Document library to Bullzip PDF
(450.99 KiB) Downloaded 84 times
utelle
Moderator
Moderator
Posts: 1125
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: Mirrored text not displayed using Adobe Acrobat

Post by utelle »

rsb wrote: Tue Jun 06, 2023 4:38 pm We have mirrored text in the design, but the text is missing or misplaced in Adobe.
One question is whether the text is really missing in the generated PDF or just not displayed due to possibly wrong use of PDF operators.

However, the sample PDFs you provided are too complex to analyze manually. Can you create a minimal sample showing the wrong behaviour and provide its source code? This would allow to further investigate the issue.
rsb wrote: Tue Jun 06, 2023 4:38 pm Using a 3rd party application called BullZip PDF the mirrored text is correct.

I've attached the PDF file for each. Can you tell me what the problem is?
Sorry, without seeing the code that generated the graphics/PDF output it is impossible to tell what's going wrong.

From the PDF file I see you used wxPdfDC to create it. Do you display the graphics on screen, too, with the same wxDC code? If yes, does it work as expected?

If possible provide some code that can be used to reproduce the problem.
rsb
I live to help wx-kind
I live to help wx-kind
Posts: 170
Joined: Fri May 29, 2015 7:26 pm

Re: Mirrored text not displayed using Adobe Acrobat

Post by rsb »

Hello,

Attached is a much smaller drawing with one mirrored text string and one non-mirrored text string.
The smaller text is reference text and is not mirrored. The mirrored text is on the bottom of the board.

The drawing on the screen (first drawing) is correct. The second drawing is displayed in Adobe generated using PDFLibrary.
The third drawing is displayed in Adobe and is generated from Bullzip PDF.

All drawings were generated using the same code. Below is a snippet of the relevant code used to display.

Code: Select all

wxPoint point = true_type_text__determine_display_origin_from_extent(text_p, text_value, displayFont, *dc, display_conversion_p) ;

if( graphics__mirror_transform(window_attribute_p, text_p) )
{
    wxAffineMatrix2D mat = dc->GetTransformMatrix() ;
    mat.Translate(point.x, point.y);
    if( graphics__get_board_view_side() != text__get_board_side(text_p) )
    {
        if( import_export.window_p->edit_p->edit_attribute_p->display_status & object_$flip_vertical )
            mat.Mirror(wxVERTICAL|wxHORIZONTAL);
        else
            mat.Mirror(wxHORIZONTAL);
    }
    else if( import_export.window_p->edit_p->edit_attribute_p->display_status & object_$flip_vertical )
    {
        mat.Mirror(wxVERTICAL);
    }

    dc->SetTransformMatrix(mat);
    if( double__equal(orientation, 0.0) )
        dc->DrawText(string_display_value, 0, 0) ;
    else
        dc->DrawRotatedText(string_display_value, 0, 0, orientation) ;
    dc->ResetTransformMatrix();
}
else
{
    if( text_p->right_reading )
    {
        if( graphics__get_board_view_side() != text__get_board_side(text_p) )
        {
            if( !(import_export.window_p->edit_p->edit_attribute_p->display_status & object_$flip_vertical) )
            {
                if( !true_type_text__check_orthogonal(orientation) )
                    orientation = orientation__set_positive(-orientation) ;
            }
        }
        else if( import_export.window_p->edit_p->edit_attribute_p->display_status & object_$flip_vertical )
        {
            if( !true_type_text__check_orthogonal(orientation) )
                orientation = orientation__set_positive(-orientation) ;
        }
    }

    if( double__equal(orientation, 0.0) )
        dc->DrawText(string_display_value, point.x, point.y) ;
    else
        dc->DrawRotatedText(string_display_value, point.x, point.y, orientation) ;
}
ScreenTrueType.PNG
ScreenTrueType.PNG (12.86 KiB) Viewed 5191 times
AdobeTrueType.PNG
AdobeTrueType.PNG (21.39 KiB) Viewed 5191 times
BullzipAdobeTrueType.PNG
BullzipAdobeTrueType.PNG (15.97 KiB) Viewed 5191 times
utelle
Moderator
Moderator
Posts: 1125
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: Mirrored text not displayed using Adobe Acrobat

Post by utelle »

rsb wrote: Wed Jun 07, 2023 3:48 pm Attached is a much smaller drawing with one mirrored text string and one non-mirrored text string.
The smaller text is reference text and is not mirrored. The mirrored text is on the bottom of the board.
Thanks for the smaller sample and the code snippet.
rsb wrote: Wed Jun 07, 2023 3:48 pm The drawing on the screen (first drawing) is correct. The second drawing is displayed in Adobe generated using PDFLibrary.
The third drawing is displayed in Adobe and is generated from Bullzip PDF.

All drawings were generated using the same code. Below is a snippet of the relevant code used to display.
In the screenshot of the sample generated with wxPdfDocument resp wxPdfDC I see that the mirrored text is slightly displaced to the left. This could indicate that something went wrong on applying the transformation matrix.

I will try to find out whether there is something wrong with the handling of transformations.
utelle
Moderator
Moderator
Posts: 1125
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: Mirrored text not displayed using Adobe Acrobat

Post by utelle »

Using wxPdfDC's default settings the transformations seem to work as expected. However, it is still possible that there is a bug when using non-default settings.

So, could you please let me know the settings you are using, namely whether you modify the resolution (wxPdfDC::SetResolution()), the mapping mode (wxDC::SetMapMode()) and/or the mapping mode style (wxPdfDC::SetMapModeStyle()) and/or the user scale (wxDC::SetUserScale()).
rsb
I live to help wx-kind
I live to help wx-kind
Posts: 170
Joined: Fri May 29, 2015 7:26 pm

Re: Mirrored text not displayed using Adobe Acrobat

Post by rsb »

We're not using any of the above settings.
utelle
Moderator
Moderator
Posts: 1125
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: Mirrored text not displayed using Adobe Acrobat

Post by utelle »

rsb wrote: Fri Jun 09, 2023 1:17 pm We're not using any of the above settings.
Well, I'm at a loss. As said, I made several experiments using default settings and it works as expected. The only idea I have is that maybe something goes wrong on calculating the transformation point based on the text extent. For example, if the text extent is calculated with a different font than is actually used by wxPdfDC to draw the text that could result in shifted text placement.
rsb
I live to help wx-kind
I live to help wx-kind
Posts: 170
Joined: Fri May 29, 2015 7:26 pm

Re: Mirrored text not displayed using Adobe Acrobat

Post by rsb »

Can I ask what application you use to display the PDF document and how do you invoke the application?

Are you invoking like we do (below) or some other method?

"C:\Program Files\Adobe\Acrobat DC\Acrobat\Acrobat.exe" "B:\190313_test-3d-lib-test-pth-comps\pantheon\BOARD.pdf"

Thanks.
utelle
Moderator
Moderator
Posts: 1125
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: Mirrored text not displayed using Adobe Acrobat

Post by utelle »

rsb wrote: Fri Jun 09, 2023 9:10 pm Can I ask what application you use to display the PDF document and how do you invoke the application?
I query the wxFileType class for the open command. Essentially, this results in invoking the default PDF viewer (Acrobat Reader on my Windows system).
rsb wrote: Fri Jun 09, 2023 9:10 pm Are you invoking like we do (below) or some other method?

"C:\Program Files\Adobe\Acrobat DC\Acrobat\Acrobat.exe" "B:\190313_test-3d-lib-test-pth-comps\pantheon\BOARD.pdf"
Yes, the open command looks similar. I doubt that the problem has anything to do with the PDF viewer.

AFAICT something goes wrong with the transformation matrix. And the most likely cause is that the translation point that is based on the text extent is not calculated correctly - resulting in misplacing the text output. My guess is that the calculation of the text extent uses a different font than that that is actually used for PDF output in wxPdfDC. However, without having access to the source code I'm not able to further debug the issue.
Post Reply