Settings for Export PDF

I would like to know if it is possible to save the settings that I use when I export a report to PDF.
Whenever I export to PDF I need to adjust these settings, I thought that maybe there is a way to save them.


Comments

  • procedure TFP3Converter.ProcessClassProperties(AClass: TObject; Ini: TIniFile; sSkipProps, sReadProps: String; RestoreMode: Boolean);

    var

     PropList: PPropList;

     ClassTypeInfo: PTypeInfo;

     ClassTypeData: PTypeData;

     //PropClassTypeData: PTypeData;

     i{, j}: integer;

     // APersistent: TPersistent;

     PropName: string;

     SkipProps, ReadProps: TStringList;


     function IsReadProp: Boolean;

       begin

         //Result := False;

         if ReadProps.Count <> 0 then

           Result := ReadProps.IndexOf(PropName) <> - 1

         else

           Result := SkipProps.IndexOf(PropName) = -1;

       end;


    begin

     ReadProps := TStringList.Create;

     ReadProps.Delimiter := ';';

     ReadProps.DelimitedText := sReadProps;

     SkipProps := TStringList.Create;

     SkipProps.Delimiter := ';';

     SkipProps.DelimitedText := sSkipProps;

     ClassTypeInfo := AClass.ClassInfo;

     ClassTypeData := GetTypeData(ClassTypeInfo);

     if ClassTypeData.PropCount <> 0 then

     begin

       GetMem(PropList, SizeOf(PPropInfo) * ClassTypeData.PropCount);

       try

         GetPropInfos(AClass.ClassInfo, PropList);

         for i := 0 to ClassTypeData.PropCount - 1 do

           begin

             PropName := string(PropList[i]^.Name);

             if IsReadProp then

    //         if not MatchText(PropName, ['Name', 'Tag', 'IOTransport', 'ShowDialog',

    //                                              'FileName', 'DefaultPath', 'ShowProgress',

    //                                              'OverwritePrompt', 'CreationTime', 'OpenAfterExport']) then

             case PropList[i].PropType^.Kind of

             {$IFDEF DELPHI16}

             tkInt64,

             {$ENDIF}

               tkInteger, tkSet, tkChar, tkWChar, tkEnumeration:

                 if RestoreMode then

                   SetOrdProp(AClass, PropName, Ini.ReadInteger(ExportFilter.ClassName, PropName, GetOrdProp(AClass, PropList[i])))

                 else

                   Ini.WriteInteger(ExportFilter.ClassName, PropName, GetOrdProp(AClass, PropList[i]));


               tkString, tkLString, tkWString{$IFDEF Delphi12}, tkUString{$ENDIF}:

               if RestoreMode then

                 SetPropValue(AClass, PropName, Ini.ReadString(ExportFilter.ClassName, PropName, VarToStr(GetPropValue(AClass, PropName))))

               else

                 Ini.WriteString(ExportFilter.ClassName, PropName, VarToStr(GetPropValue(AClass, PropName)));

             end;

           end;


       finally

         FreeMem(PropList, SizeOf(PPropInfo) * ClassTypeData.PropCount);

       end;

       SkipProps.Free;

       ReadProps.Free;

     end;

    end;


    procedure TFP3Converter.RestoreSettings;

    var Ini: TIniFile;

    begin

     Ini := TIniFile.Create(ExtractFilePath(ParamStr(0)) + 'settings.ini');

     ProcessClassProperties(ExportFilter, Ini, SkippedProperties, '', True);

     if ExportFilter.ClassName = 'TfrxPDFExport' then

       Ini.ReadBool(ExportFilter.ClassName, 'SaveOriginalImages', True);

     Ini.Free;

    end;


    procedure TFP3Converter.SaveSettings;

    var Ini: TIniFile;

    begin

       Ini := TIniFile.Create(ExtractFilePath(ParamStr(0)) + 'settings.ini');

       ProcessClassProperties(ExportFilter, Ini, SkippedProperties, '', False);

       if ExportFilter.ClassName = 'TfrxPDFExport' then

         Ini.WriteBool(ExportFilter.ClassName, 'SaveOriginalImages', TfrxPDFExport(ExportFilter).SaveOriginalImages);

       Ini.Free;

       {procedure SetClassProperties(AClass: TObject; sSkipProps, sReadProps: String);

        если sReadProps пустой , то читаем все св-ва, игнорируя св-ва из sSkipProps

        если указан sReadProps , то читаем только эти св-ва }

    end;

  • edited February 2020

    Sorry, but can you explain better? I did not understand.

  • If this code is hard for you - just store properties what you need in the ini file

    Ini.WriteBool('TfrxPDFExport', 'SaveOriginalImages', TfrxPDFExport(ExportFilter).SaveOriginalImages);

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.