Portable-Document-Format-Plugin-for-Paint.NET icon indicating copy to clipboard operation
Portable-Document-Format-Plugin-for-Paint.NET copied to clipboard

Building

Open bananakid opened this issue 1 year ago • 3 comments

I downloaded Portable-Document-Format-Plugin project and the corresponding PDFiumSharp project.

Then I put PDFiumSharp project files into Portable-Document-Format-Plugin\PDFiumSharp directory.

Then I downloaded paint.net 4.2.16, installed it and copied PaintDotNet.Base.dll, PaintDotNet.Base.pdb, PaintDotNet.Core.dll, PaintDotNet.Core.pdb, PaintDotNet.Data.dll, PaintDotNet.Data.pdb to Portable-Document-Format-Plugin directory.

Then I opened Portable-Document-Format-Plugin\PdfFileTypePlugin.sln and did used Run Custom Tool on FPDF_Typedefs.tt and PDFium.tt of PDFiumSharp → Types (as explained in this issue).

However, when I attempt to build PdfFileType project, I receive 3 errors:

Severity	Code	Description	Project	File	Line	Suppression State
Error	CS1061	'Surface' does not contain a definition for 'Fill' and no accessible extension method 'Fill' accepting a first argument of type 'Surface' could be found (are you missing a using directive or an assembly reference?)	PdfFileType (net5.0-windows)	C:\Portable-Document-Format-Plugin\PdfFileType\Import\PdfImport.cs	287	Active
Error	CS1061	'Surface' does not contain a definition for 'Fill' and no accessible extension method 'Fill' accepting a first argument of type 'Surface' could be found (are you missing a using directive or an assembly reference?)	PdfFileType (net5.0-windows)	C:\Portable-Document-Format-Plugin\PdfFileType\Export\PdfExporter.cs	99	Active
Error	CS1061	'Surface' does not contain a definition for 'Fill' and no accessible extension method 'Fill' accepting a first argument of type 'Surface' could be found (are you missing a using directive or an assembly reference?)	PdfFileType (net5.0-windows)	C:\Portable-Document-Format-Plugin\PdfFileType\Export\PdfExporter.cs	108	Active

How can I workaround this?

bananakid avatar May 07 '24 12:05 bananakid

Hi,

paint.net 4.2.16 utilizes .NET Framework 4.7. However, the errors you're encountering are for .NET 5 (which is for paint.net versions >=5). This project employs multitargeting, compiling the plugin for both paint.net 4 and paint.net 5 simultaneously. Nonetheless, you can only have one paint.net version installed on your system. In my case, I had installed paint.net 5, but I hadn't installed paint.net 4.2.16. Instead, I had only copied its libraries into a folder. The project configuration assumes paint.net 5 is installed by default.

The problem is, You're attempting to use paint.net 4.2.16's assemblies to compile the plugin for paint.net 5, resulting in these errors.

Solution: If you don't have paint.net 5 installed or don't want to compile against it you can edit the main project file (PdfFileType.csproj) and remove net5.0-windows from TargetFrameworks

There's also no need to copy those assemblies into the directory (which wouldn't have any effect); you can simply set the PdnRoot variable in the project file. It should point to your paint.net installation directory:

  <PropertyGroup Condition="'$(TargetFramework)'=='net47'">
    <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
    <PdnRoot>D:\Backup\Programlar\paint.net_4216</PdnRoot> <!-- should point to your paint.net 4.2.16 installation folder -->
    <PluginDir>$(PdnRoot)\$(PluginType)s\</PluginDir>
  </PropertyGroup>

I plan to discontinue support for 4.2.16 and clean up the project soon.

otuncelli avatar May 07 '24 20:05 otuncelli

Thanks for in-depth explanation, @otuncelli! My goal was just to make file type name of your plugin in Save As… dialog shorter: keep it simply PDF instead of PDF - Portable Document Format Plugin v1.0.0.1 (as this can break the dialog sometimes). So I was to edit lines 24 & 106 in PdfFileType.cs and recompile, like this:

public PdfFileType(FileTypeOptions options) : base(GetName("PDF"), options)
…
=> $"{baseName}";

Following your guidance, I succeeded in recompiling without errors by downloading and extracting 4.2.16 and 4.3.0 to paths specified in corresponding PdnRoot of project file (I used C:\Program Files\paint.net_4216 and C:\Program Files\paint.net_4300 paths of PdnRoot instead of yours), and then installing 5.0.10 to C:\Program Files\paint.net.

However, I can only open PDF with my re-compiled DLL. When I attempt to save multi-layer PDN file to PDF with my build, I then get only first visible layer to get saved (and my preview window works and calculates file size correctly, which is different from your build). I have tried re-compiling using paint.net 5.0.1 (as low as I can get with 5-th release), but it didn't help. Since it looks like it requires substantial effort to fix and there's no hints (like errors or warnings), I think I shouldn't touch it further (to not break something).

To summarize, may I request a shorter filetype description for Save As… dialog for the upcoming updated build? Since there's only one other working plugin currently and it uses Im(age)PDF (*.pdf) file type description for Save As… dialog, I believe the simple PDF (*.pdf) or PDF Plugin (*.pdf) will be perfect for your plugin.

bananakid avatar May 08 '24 06:05 bananakid

To summarize, may I request a shorter filetype description for Save As… dialog for the upcoming updated build?

Sure. I'm leaving this issue open as a reminder.

otuncelli avatar May 09 '24 23:05 otuncelli

Fixed with the new release.

otuncelli avatar Nov 26 '24 23:11 otuncelli

@otuncelli, thanks for a smooth update and thanks for addressing the issue we discussed! So far so good. I'll try to recompile it once I get a chance and will report if anything goes not as expected.

bananakid avatar Nov 27 '24 01:11 bananakid