#1 Re: PDF Engine » SynPDF Encryption makes Document Information unreadable » 2020-11-10 08:15:11

Wolfgang Haefele wrote:

If encryption is turned on, the properties shown by Adobe Acrobat change from readable strings to typical RC4-coded strings:
Title: 'Ł\ ²¾'
Author: '>3“ ñb ˛3¨°F já'
Subject: 'yRÈú`œ–çJ'

I am facing the same problem:
If encryption is activated, the document properties contain garbage. This was not the case in older versions of SynPDF, but I could not find out which revision introduced this problem.


#2 Re: PDF Engine » Create protected PDF » 2020-01-21 07:39:51

We are facing the very same problem:

Creating a protected PDF makes the information fields (Title, Author, Creator, Subject) unreadable when opening the PDF in Adobe Reader (or any other PDF viewer like Foxit Reader, even Google Chrome).

This used to work in past versions (can't tell which one; but I think this bug was introduced lately).

I've created an issue ticket on Github:

Hopefully @ab will fix this as soon as possible.

Many thanks in advanve,

#3 Re: GDI+ » JPEG images get distorted » 2019-09-11 14:55:32

ab wrote:

I meant low-level error, to retrieve via the IDE debugger.
Does it mean that the conversion works, but the resulting file is incorrect (as the file you uploaded)?

Yes, the resulting file is incorrect.

I don't have access to the customer's computer for debugging, but I will try to establish a VPN connection using TeamViewer and then do Remote debugging. Any experience with this setup?

#4 Re: GDI+ » JPEG images get distorted » 2019-09-11 11:44:23

ab wrote:

Are you using the latest version of SynPDF + SynGdiPlus units?

I use V1.18 with my enhanced clipping processing patch (EMR_EXTSELECTCLIPRGN; this patch was first accepted but later removed from SynPDF.pas). My local fork still contains this enhancements because some of the images I need to put into PDF include non-rectangular clipping areas -- but not the failed logo image. Besides of that I use the up-to-date code.

But I think it does not matter: The very same executable on my computer creates good-looking JPEG files, on the customers computer the JPEG is bad. Did you had a look at the example image?

ab wrote:

What is the exact error triggered by GdipTest ?

There is no error message;


just completes.


#5 GDI+ » JPEG images get distorted » 2019-09-11 09:53:16

Replies: 4

Hello *, hello AB.

I have a strange problem while creating PDF files using SynPDF. The page contains a company logo bitmap, ForceJPEGCompression is set to 85. In the resulting PDF file, the logo bitmap is heavily distored; it looks like over-compression. I've tracked down the problem to the JPEG encoder used in SynGdiPlus.pas. There is a procedure GdipTest() which I used to verify the problem: The input file is converted fine to BMP, GIF and PNG, but fails on JPEG image. (I'll try to attach a sample graphic).

Logo example
https://drive.google.com/open?id=1VI_SI … cGKEGMuX-i

The strange thing is: This happens only on customer's computer, which is Windows 10 Pro V1809. On my computer (also Windows 10 Pro V1809) everything works fine. GdiPlus.dll is loaded from
(I did not specify this path, Windows has some kind of magic for loading this DLL)

The GdiPlus.dll version on customer's computer and on my system are the same: v10.0.17763.678

So my questions are:
- besides GdiPlus.dll, which other modules/libraries are involved when creating JPEG images from SynGdiPlus?
- dre there any known problems with GdiPlus and JPEG images?
- does GdiPlus use any configuration options/parameters/registry?


#6 Re: PDF Engine » Latest SynPdf version breaks the clipping » 2017-05-19 14:15:10

Today I updated my local copy of SynPDF to the latest trunk version, mostly to get the PDF/A fix; but also to find out that my ExtSelectClipRgn() code was reverted in SVN revision 150.

My code was able to handle non-rectangular clipping areas by interpreting the Region arrays from Windows. Now the old code is active again, which can handle a single rectangle clipping area only. And I have the feeling that even this simple code is wrong, because Data.rcBounds is never used.

I've created a local branch and merged my code back into SynPDF.pas; with some small adjustments as mentioned where by MtwStark: Test for iMode == RGN_COPY. Now everything works fine, again.

AB, can you please dig into your version control software to find out if there was a specific bug, which lead to reverting my enhancements?!


What would be needed to support PDF/A-3 with attachments (ZUGFeRD, an ugly german acronym for embedding invoice data as XML into PDF documents): http://www.ferd-net.de/front_content.php?idcat=231

#8 Re: PDF Engine » Embedding OpenType Fonts (otf)? » 2014-09-26 07:36:33

Hello ab,

I've modified the function ENumFontsProcW as following:

"var TextMetric" changed from TTextMetric to TNewTextMetric as described in MSDN documentation:
http://msdn.microsoft.com/en-us/library … 85%29.aspx

Now I can test TextMetric.ntmFlags for OpenType fonts.
With that new modified code, the "Myriad Pro" font gets embedded into the PDF file.

However, the PDF file size increases from 5 KB (not embedded) to 180 KB (EmbeddedWholeTTF = False) and up to 510 KB (EmbeddedWholeTTF = True), but the OpenType font file is only 94 KB. I don't know why the PDF gets that large. And I don't have any tools to analyze the PDF files.

Here are my changes:

  NTM_PS_OPENTYPE = (1 shl 17);  // Bit 17: PostScript OpenType font
  NTM_TT_OPENTYPE = (1 shl 18);  // Bit 18: TrueType OpenType font

function EnumFontsProcW(var LogFont: TLogFontW; var TextMetric: TNewTextMetric;
  FontType: Integer; var List: TRawUTF8DynArray): Integer; stdcall;
// we enumerate all available fonts, whatever the charset is, because
// we may won't enumerate Arial or Times New Roman if current FCharSet is
// chinese e.g.
var Temp: RawUTF8;
  with LogFont do
    if (   (FontType=TRUETYPE_FONTTYPE) 
        or ((TextMetric.ntmFlags and NTM_PS_OPENTYPE) <> 0) // <<< added
        or ((TextMetric.ntmFlags and NTM_TT_OPENTYPE) <> 0) // <<< added
    and (lfFaceName[0]<>'@')
    then begin
      Temp := RawUnicodeToUtf8(lfFaceName,StrLenW(lfFaceName));
      if (pointer(List)=nil) or (List[high(List)]<>Temp) then
  Result := 1;

Nevertheless I will submit a feature request.


#9 PDF Engine » Embedding OpenType Fonts (otf)? » 2014-09-25 15:11:55

Replies: 4


I need to create PDF from RichText documents, which uses fonts from the "Myriad Pro" family (Adobe). The fonts are installed as OpenType fonts on the Windows 7 machine.

When creating PDF documents using TPdfDocumentGDI with EmbeddedTTF := True, those fonts are NOT embedded into the PDF file; all text uses "Arial Unicode MS" as fallback; which looks not as desired when viewing the PDF on a different computer (without those fonts installed).

I've tracked down the problem to function EnumFontsProcW in TPdfDocument: Only fonts which are pure TrueType fonts are collected in FTrueTypeFonts array.
What would be necessary to also embed OpenType fonts into the PDF document?


#10 Re: PDF Engine » PDF file looks different using SynPDF V1.18: vertical mirrored images » 2013-09-04 11:19:58

Sorry, copy & paste error :-(
The new code is indeed using


but that doesn't explain why the old code works fine, while the new code doesn't.

Any ideas how to solve that problem?

#11 Re: PDF Engine » PDF file looks different using SynPDF V1.18: vertical mirrored images » 2013-09-04 08:23:15


I finally found some time to analyze this problem:

In SynPDF V1.18 there was a small code change in function TPdfCanvas.RectI(): The call to NormalizeRect() was moved from top to bottom of that function:



  function TPdfCanvas.RectI(Rect: TRect): TPdfRect; TPdfRect;
    NormalizeRect(Rect);          <<<<<<<<<<
    result.Left := I2X(Rect.Left);
    result.Right := I2X(Rect.Right); 
    result.Top := I2Y(Rect.Bottom); 
    result.Bottom := I2Y(Rect.Top);


  function TPdfCanvas.RectI(Rect: TRect): TPdfRect; TPdfRect;
    result.Left := I2X(Rect.Left);
    result.Right := I2X(Rect.Right); 
    result.Top := I2Y(Rect.Bottom); 
    result.Bottom := I2Y(Rect.Top);
    NormalizeRect(Rect);          <<<<<<<<<<

The call to NormalizeRect() was moved from the first line to the last line of the code, causing my mirrored bitmaps to appear non-mirrored. If I change this function back to the older version, my PDF files look OK again.

But I think there was some very good reason to change the behaviour of TPdfCanvas.RectI(), however I do not know that reason.

Here is a sample EMF file which I used for testing:
https://dl.dropboxusercontent.com/u/562 … bitmap.emf

Is reverting the code of TPdfCanvas.RectI() back to version 1.17 the correct solution?


#13 PDF Engine » PDF file looks different using SynPDF V1.18: vertical mirrored images » 2013-04-19 09:06:03

Replies: 7

Hello *,

After upgrading from SynPDF v1.15 to the latest version v1.18 my PDFs looks different: Some images are no longer flipped (or mirrored) as they used to be in the older version.

In detail:
I'm using QuickReport; and I use TPdfDocumentGDI to render QuickReport's pages (which are Windows EMF) into PDF. Some parts of this Metafiles are images (bitmaps), which need to be mirrored on the vertical axis to create a "left hand" and "right hand" look. I create those mirrored bitmaps by swapping left and right coordinates; which looks OK on display, in the print preview and on printer output (paper).
It also used to be OK with older SynPDF version, but after installing latest v1.18, those images are no longer mirrored in the PDF!

So what has been changed in SynPDF?
Perhaps the better question: How could I create a vertical mirrored bitmap which will look as intended in the PDF?

Screenshots of PDF in Adobe Reader X:
https://dl.dropboxusercontent.com/u/562 … _v1-15.jpg
https://dl.dropboxusercontent.com/u/562 … _v1-18.jpg


#14 PDF Engine » Setting PDF permissions » 2011-04-18 11:12:34

Replies: 1

Hello *,

how can I change the PDF protection permissions, such as a disallow document assemby or modifications?


#15 Re: PDF Engine » Canvas pen width versus PDF pen width » 2011-04-18 11:00:02

ab wrote:

You could increase the ScreenLogPixels value, so that it will increase the resolution of the VCLCanvas.
Default value is 72, but you could set it e.g. to 144.
The ScreenLogPixels must be set before the first use of VCLCanvas.
In this case, a VCLCanvas.Pen.Width of 1 will be smaller when rendered on pdf content.

I'm in the same situation to change the resolution, and I was very happy to read the "solution" here. Unfortunately "ScreenLogPixels" is a read only property (Version 1.12).

Please assist.

Board footer

Powered by FluxBB