Syncfusion.Pdf.Base and Syncfusion.Pdf.Portable - different assemblies in one codeShareProject

I have one core project, type of CodeShareProject in Visual, which other projects use.

Other projects are: Xamarin Mobile App and WinForms on desktop.

Xamarin App use assembly Syncfusion.Pdf.Portable (from Syncfusion.Xamarin.Pdf) to generate pdfs, and desktop app use assembly Syncfusion.Pdf.Base(from Syncfusion.WinForms.Pdf).

Then I have conflicts, because for example PdfDocument is in both: Syncfusion.Pdf.Base and Syncfusion.Pdf.Portable.



How to resolve this? Someone knows? Thanks in advance!

7 Replies 1 reply marked as answer

SL Sowmiya Loganathan Syncfusion Team March 19, 2021 12:25 PM UTC

Hi Patrycja,   
  
Thank you for contacting Syncfusion support.   
  
We have analyzed the reported issue “PdfDocument' exists in both Syncfusion.Pdf.Base and Syncfusion.Pdf.Portable" and we can overcome this by adding alias for the dll “Syncfusion.Pdf.Portable.dll”. Please refer the below code snippet for more details,     
    
.CSProj file changes:     
<Target Name="ChangeAliases"BeforeTargets="FindReferenceAssembliesForReferences;ResolveReferences">    
  <ItemGroup>    
    <ReferencePath Condition="'%(FileName)' == 'Syncfusion.Pdf.Portable'">    
      <Aliases>global,syncfusionPortable</Aliases>    
    </ReferencePath>    
  </ItemGroup>    
</Target>    
  
Class file changes:   
extern alias syncfusionPortable;   
   
//Create PDF document   
syncfusionPortable::Syncfusion.Pdf.PdfDocument document = new syncfusionPortable::Syncfusion.Pdf.PdfDocument;   
  
  
Can you please try the above suggestion in your end and let us know the result. If you have facing any issue, please provide us the below details. It will helpful for us to provide the precise solution on this.   
  
  • Platform (Xamarin Forms or WinForms)  
  • Product version
  
Regards,  
Sowmiya Loganathan  
 


Marked as answer

CR Chetan R October 23, 2024 01:28 PM UTC

Hi Team,

As per your suggestion, creating Aliases works in one of my projects, where we added the references for the DLLs and used them with different Alias names.

However, I am facing an issue in a different WinForms ASPX project. In this project, we place the required DLL files in the bin folder and do not add them as explicit references in the project. I attempted to declare the alias directly in the project code as follows:

html

<% Import Namespace="SyncPortable::Syncfusion.Pdf.Portable" %>

However, this was not accepted. When I tried:

html

<% Import Namespace="SyncPortable::Syncfusion.Pdf" %>

it accepted the alias, but I encountered the same error:


'PdfLoadedDocument' exists in both 'Syncfusion.Pdf.Base' and 'Syncfusion.Pdf.Portable'.


I would appreciate your guidance on how to properly declare aliases or avoid conflicts in a scenario where I cannot add direct references to the libraries and must rely on placing the DLLs in the bin folder.

Looking forward to your assistance.


Best regards,

Chetan Raivadera



IJ Irfana Jaffer Sadhik Syncfusion Team October 24, 2024 01:23 PM UTC

Hi Chetan,


While adding the above provided solution, the reported conflicts will not occurs. We have created the simple sample to illustrate this and please find the download link from below,


Samplehttps://www.syncfusion.com/downloads/support/directtrac/general/ze/PdfSample-1274997518


Please try the above sample in your end and let us know the result. If you are still facing an issue, we request you to share the modified sample with us. so that we can assist with you further in this.


Regards,

Irfana





SI Signer.Digital October 25, 2024 10:41 AM UTC

Hi Irfana,

You have replied with the solution given earlier only.

I had mentioned clearly - that way it is working in .Net project, where in the References, I can give a separate named alias for the library instead of global from the properties. (you can refer the screenshot attached)


The other project I am talking about is a ASPX page, where I can keep the library in bin folder only and do not have option to change alias from references - properties.

Please provide a solution for this case.

Code Example:

<%@ Page Language="C#" %>

<%@ Import Namespace="System.IO" %>

<%@ Import Namespace="System.Threading.Tasks" %>

<%@ Import Namespace="System.Security.Cryptography.X509Certificates" %>

<%@ Import Namespace="SyncBase=Syncfusion.Pdf" %> 

"SyncBase= SyncBase=Syncfusion.Pdf.Portable" does not provide the portable library reference to the project and gives error as Portable is not available in Syncfusion.Pdf )

Code Example:

public string DoSignPDF(string SelCert, string SDHubConnectionId)

    {

        string inFileName = @"C:\Test\MultiPageTest.pdf";

        string outFileName = @"C:\Test\AspxSignedPDF.pdf";

        TxnRespWithFile txnResp = new TxnRespWithFile() { IsSuccess = true };

        try

        {

            byte[] sourcefile = File.ReadAllBytes(inFileName);

            SyncBase.Parsing.PdfLoadedDocument document = new SyncBase.Parsing.PdfLoadedDocument(sourcefile);


This gives the error: 


The type 'PdfLoadedDocument' exists in both 'Syncfusion.Pdf.Base, Version=19.4460.0.56, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89' and 'Syncfusion.Pdf.Portable, Version=26.1.40.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89' 6_SignPDF.aspx

Awaiting a positive reply from you. Thankyou.



Attachment: Solution_f543d3a8.zip


IJ Irfana Jaffer Sadhik Syncfusion Team October 25, 2024 12:55 PM UTC

Hi Chetan,


We are currently checking your requirement to resolve the reported issue and we will provide the further details on or before October 29th, 2024.


Regards,

Irfana J.



IJ Irfana Jaffer Sadhik Syncfusion Team October 29, 2024 10:41 AM UTC

Hi Chetan,


Thank you for bringing this issue to our attention. We understand that you are facing conflicts when using Syncfusion.Pdf.Base and Syncfusion.Pdf.Portable assemblies in your ASPX project. Unfortunately, due to the nature of ASPX projects and the lack of direct support for aliasing assemblies without a .csproj file, there are inherent limitations that prevent us from resolving this conflict effectively. Due to this limitation, we cannot directly use both assemblies in the ASPX project.

Therefore, we recommend using only one of the packages based on your requirements. The Syncfusion.Pdf.Net.Core package (Syncfusion.Pdf.Portable) supports cross-platforms, and both assemblies offer almost the same set of features.

We request you to provide your exact requirements for using both platforms so that we can explore alternatives and provide you with a prompt solution.


Regards,

Irfana J.




SI Signer.Digital November 9, 2024 05:09 AM UTC

Thankyou for the update Irfana.

Regars,


Loader.
Up arrow icon