Coder Social home page Coder Social logo

vahidn / itextsharp.lgplv2.core Goto Github PK

View Code? Open in Web Editor NEW
589.0 29.0 149.0 22.87 MB

iTextSharp.LGPLv2.Core is an unofficial port of the last LGPL version of the iTextSharp (V4.1.6) to .NET Core

License: Other

C# 99.98% HTML 0.02% Batchfile 0.01%
itextsharp pdf aspnetcore asp-net-core

itextsharp.lgplv2.core's Introduction

iTextSharp.LGPLv2.Core

iTextSharp.LGPLv2.Core

iTextSharp.LGPLv2.Core is an unofficial port of the last LGPL version of the iTextSharp (V4.1.6) to .NET Core.

Install via NuGet

To install iTextSharp.LGPLv2.Core, run the following command in the Package Manager Console:

Nuget

PM> Install-Package iTextSharp.LGPLv2.Core

You can also view the package page on NuGet.

Linux (and containers) support

The SkiaSharp library needs extra dependencies to work on Linux and containers. Please install the following NuGet packages:

PM> Install-Package SkiaSharp.NativeAssets.Linux.NoDependencies
PM> Install-Package HarfBuzzSharp.NativeAssets.Linux

You also need to modify your .csproj file to include some MSBuild directives that ensure the required files are in a good place. These extra steps are normally not required but seems to be some issues on how .NET loads them.

<Target Name="CopyFilesAfterPublish" AfterTargets="AfterPublish">
    <Copy SourceFiles="$(TargetDir)runtimes/linux-x64/native/libSkiaSharp.so" DestinationFolder="$([System.IO.Path]::GetFullPath('$(PublishDir)'))/bin/" />
    <Copy SourceFiles="$(TargetDir)runtimes/linux-x64/native/libHarfBuzzSharp.so" DestinationFolder="$([System.IO.Path]::GetFullPath('$(PublishDir)'))/bin/" />    
</Target>

Usage

Functional Tests

FAQ

The pdf is created, but when I try to view it, it says that the document is in use by another process.

You should dispose the FileStream/MemoryStream explicitly. It won't be closed and disposed automatically at the end.

I can't find what would be the equivalent of the PdfTextExtractor class.

PdfTextExtractor exists in v5.0.2+ with AGPL license (Current project is based on the iTextSharp 4.x, not 5.x).

It can't display Unicode characters.

You can find more samples about how to define and use Unicode fonts here.

Table rowspans don't work correctly.

This version which is based on iTextSharp V4.1.6 doesn't support rowspans correctly (iTextSharp supports row spans correctly since v5.4.3, not before that). A solution based on the current version: use nested tables to simulate it.

iTextSharp.text.html.simpleparser.HTMLWorker does not exist.

It has been renamed to HtmlWorker.

Licensing

You have three license choices when it comes to iTextSharp: LGPL/MPL, AGPL, or a commercial license. The LGPL/MPL license is only an option with the older 4.1.6 version (used here). After that version, they switched to a dual AGPL/Commercial.

If you need a more recent version, you either have to make your project open-source or pay the license fee.

itextsharp.lgplv2.core's People

Contributors

anisite avatar deepumi avatar dependabot[bot] avatar jorge-ribeiro-evaltec avatar kirillkaverin avatar kosmakoff avatar marcelolrodrigues avatar michaelcheers avatar ookriangsakoo avatar orondf343 avatar raulfpl avatar rossgeerlings avatar sappharad avatar shane32 avatar vahidn avatar zubastic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

itextsharp.lgplv2.core's Issues

can't display Chinese characters

I'm a chinese people ,I am very grateful to you wrote so good a tool. In you under the help of this tool I can convert word files to PDF . but I met a difficulty when I use you tool to add some chinese character to the pdf file which I want to creat . in the created pdf file it can not display the chinese character ,because I am a entry-level programmer .it is too difficult to me ,so I'd like you to help me with my how to solve this problem. I will be very grateful to you.

Erro when I try generate PDF in Android

Summary of the issue

When I tried execute the line in Android device.

Paragraph paragrafo = new Paragraph(dados, new iTextSharp.text.Font(iTextSharp.text.Font.NORMAL, 14));

I have de error below:
Could not load file or assembly 'System.Runtime.Loader, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.

Environment

Android only.

iTextSharp.LGPLv2.Core version: 1.6.0
.NET Core SDK version: 2.0.3
IDE: Visual Studio 2017

Example code/Steps to reproduce:

Document doc = new Document();

                PdfWriter writer = PdfWriter.GetInstance(doc, ms);
                doc.AddTitle("Termo");
                doc.Open();

                string dados = "";

                Paragraph paragrafo = new Paragraph(dados, new iTextSharp.text.Font(iTextSharp.text.Font.NORMAL, 14)); - ERROR

Output:

Exception message: Could not load file or assembly 'System.Runtime.Loader, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.

Full Stack trace:
  at iTextSharp.text.pdf.Type1Font..ctor (System.String afmFile, System.String enc, System.Boolean emb, System.Byte[] ttfAfm, System.Byte[] pfb, System.Boolean forceRead) [0x0011d] in <6d01038280c1418fbfdfc4080d8a4899>:0 
  at iTextSharp.text.pdf.BaseFont.CreateFont (System.String name, System.String encoding, System.Boolean embedded, System.Boolean cached, System.Byte[] ttfAfm, System.Byte[] pfb, System.Boolean noThrow, System.Boolean forceRead) [0x000be] in <6d01038280c1418fbfdfc4080d8a4899>:0 
  at iTextSharp.text.pdf.BaseFont.CreateFont (System.String name, System.String encoding, System.Boolean embedded, System.Boolean cached, System.Byte[] ttfAfm, System.Byte[] pfb, System.Boolean noThrow) [0x00000] in <6d01038280c1418fbfdfc4080d8a4899>:0 
  at iTextSharp.text.pdf.BaseFont.CreateFont (System.String name, System.String encoding, System.Boolean embedded) [0x00000] in <6d01038280c1418fbfdfc4080d8a4899>:0 
  at iTextSharp.text.Font.GetCalculatedBaseFont (System.Boolean specialEncoding) [0x0012e] in <6d01038280c1418fbfdfc4080d8a4899>:0 
  at iTextSharp.text.pdf.PdfChunk..ctor (iTextSharp.text.Chunk chunk, iTextSharp.text.pdf.PdfAction action) [0x0008f] in <6d01038280c1418fbfdfc4080d8a4899>:0 
  at iTextSharp.text.pdf.PdfDocument.Add (iTextSharp.text.IElement element) [0x001d8] in <6d01038280c1418fbfdfc4080d8a4899>:0 
  at iTextSharp.text.Phrase.Process (iTextSharp.text.IElementListener listener) [0x00015] in <6d01038280c1418fbfdfc4080d8a4899>:0 
  at iTextSharp.text.pdf.PdfDocument.Add (iTextSharp.text.IElement element) [0x00549] in <6d01038280c1418fbfdfc4080d8a4899>:0 
  at iTextSharp.text.Document.Add (iTextSharp.text.IElement element) [0x00067] in <6d01038280c1418fbfdfc4080d8a4899>:0 
  at e_Beauty.Helpers.CreatePDF.NewPDF (System.IO.Stream file, System.IO.Stream file2) [0x00123] in /Users/henriquequeirozdrumond/e-Beauty2/e_Beauty/Helpers/CreatePDF.cs:52 

Convert PDF file to image file

Hi,
I have multipage PDF files. I try to read page by page and get each page data as byte array to save as jpeg files. However, I couldn't find out why I am getting Parameter is not valid exception.
Here is my sample code.
Could you please about my issue? How can I save my each page of pdf as a jpg file.
Note: My test pdf file contains only images.
Thanks!
Emre.
image

Document in use until .net process is ended

I'm having an issue where when I create a document in a .net core web app. The pdf is created, but when I try to view it is says that the document is in use by another process. I have to stop my web app in order to see the created pdf. I've been using itextsharp for years and in my old version I didn't have this issue.
Below is some code i'm using to create the pdf.

var document = new Document();
PdfWriter.GetInstance(document, new FileStream(path + "\\" + lastName + ", " + firstName + " " + todaysDate + ".pdf", FileMode.Create));
document.Open();

Do some work on document (code omitted for brevity)

document.Close();

Qr-code

Summary of the issue

I need to print qr-code

Environment

Windows - linux

The in-use version:
Operating system: 
IDE: (e.g. Visual Studio 2017)

Multiple fonts not working in Phrase

Summary of the issue

I have added multiple TTF fonts to font factory. When adding a phrase I have two blocks of text in two separate chunks added to the phrase, each of these chunks has a different font (retrieved from the font factory) when rendering the text all looks exactly the same.

Environment

The in-use version: v1.5.0
Operating system: macOS
IDE: Visual Studio Code
Language: C# / dotnet core 2.2

Example code/Steps to reproduce:

Apologies for some of the method calls here, but this is what I am using to detect a change in font (between runs) and if it is different alter it.

I can see that the new font is being successfully retrieved from the font factory, and I can see it being correctly added to the chunk. I have checked the font files and the fonts are noticeably different to look at (one being a lot thinner) but when it is rendered it is all the same (with what appears to be the original font)

FontFactory.Register("Fonts/TTF/Swis721-BT.ttf", "SWIS721-BT");
FontFactory.Register("Fonts/TTF/Swis721-Thin-BT.ttf", "SWIS721-THIN-BT");

...

foreach (var run in textElement.Runs)
{
    var runFont = originalFontFromFactory;
    if(run.FontFamily != textElement.FontFamily && !String.IsNullOrEmpty(run.FontFamily))
    {
        runFont = FontFactory.GetFont(FontNameConvertor.GetAliasForMapItemFont(run.FontFamily), textElement.FontSize + (adjustment.IncreaseFont + increaseFont))
    }
    var chunk = new Chunk($"\u00A0{run.Text}\u00A0", runFont);
    phrase.Add(chunk);
}

Output:

Actual Result
Screenshot 2019-05-10 at 11 49 37

Expected Result
Screenshot 2019-05-10 at 11 50 22

Font 'STSongStd-Light' with 'UniGB-UCS2-H' is not recognized.

Hello, I meet a problem that when I try to use 'SetField' ,it raises '{iTextSharp.text.DocumentException: Font 'STSongStd-Light' with 'UniGB-UCS2-H' is not recognized.
at iTextSharp.text.pdf.BaseFont.CreateFont(String name, String encoding, Boolean embedded, Boolean cached, Byte[] ttfAfm, Byte[] pfb, Boolean noThrow, Boolean forceRead)
at iTextSharp.text.pdf.DocumentFont..ctor(PrIndirectReference refFont)
at iTextSharp.text.pdf.AcroFields.DecodeGenericDictionary(PdfDictionary merged, BaseField tx)
at iTextSharp.text.pdf.AcroFields.GetAppearance(PdfDictionary merged, String text, String fieldName)
at iTextSharp.text.pdf.AcroFields.SetField(String name, String value, String display)'

System.Runtime.Loader can´t load

Summary of the issue

I try compile my app to Android and IDE send me the erro below:

Could not resolve type with token 010000b5 from typeref (expected class 'System.Runtime.Loader.AssemblyLoadContext' in assembly 'System.Runtime.Loader, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a')

When I try execute the line in my code:

paragrafo.Font = new iTextSharp.text.Font(iTextSharp.text.Font.NORMAL, 14, (int)System.Drawing.FontStyle.Bold);

Environment

Visual Studio 2017

iTextSharp.LGPLv2.Core version: 1,6,1
.NET Core SDK version: 2.0.3
IDE: Visual Studio 2017

Example code/Steps to reproduce:

paste your core code
 Paragraph paragrafo = new Paragraph(dados, new iTextSharp.text.Font(iTextSharp.text.Font.NORMAL, 14));
                    paragrafo.Alignment = iTextSharp.text.Element.ALIGN_JUSTIFIED;
                    paragrafo.Font = new iTextSharp.text.Font(iTextSharp.text.Font.NORMAL, 14, (int)System.Drawing.FontStyle.Bold);
                    paragrafo.Add("Nome Profissional: " + App.Name);
                    paragrafo.Alignment = iTextSharp.text.Element.ALIGN_JUSTIFIED;
                    doc.Add(paragrafo);

## Output:

Exception message:Could not resolve type with token 010000b5 from typeref (expected class 'System.Runtime.Loader.AssemblyLoadContext' in assembly 'System.Runtime.Loader, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a')

Full Stack trace:

  at iTextSharp.text.pdf.Type1Font..ctor (System.String afmFile, System.String enc, System.Boolean emb, System.Byte[] ttfAfm, System.Byte[] pfb, System.Boolean forceRead) [0x0011d] in <6d01038280c1418fbfdfc4080d8a4899>:0 
  at iTextSharp.text.pdf.BaseFont.CreateFont (System.String name, System.String encoding, System.Boolean embedded, System.Boolean cached, System.Byte[] ttfAfm, System.Byte[] pfb, System.Boolean noThrow, System.Boolean forceRead) [0x000be] in <6d01038280c1418fbfdfc4080d8a4899>:0 
  at iTextSharp.text.pdf.BaseFont.CreateFont (System.String name, System.String encoding, System.Boolean embedded, System.Boolean cached, System.Byte[] ttfAfm, System.Byte[] pfb, System.Boolean noThrow) [0x00000] in <6d01038280c1418fbfdfc4080d8a4899>:0 
  at iTextSharp.text.pdf.BaseFont.CreateFont (System.String name, System.String encoding, System.Boolean embedded) [0x00000] in <6d01038280c1418fbfdfc4080d8a4899>:0 
  at iTextSharp.text.Font.GetCalculatedBaseFont (System.Boolean specialEncoding) [0x0012e] in <6d01038280c1418fbfdfc4080d8a4899>:0 
  at iTextSharp.text.pdf.PdfChunk..ctor (iTextSharp.text.Chunk chunk, iTextSharp.text.pdf.PdfAction action) [0x0008f] in <6d01038280c1418fbfdfc4080d8a4899>:0 
  at iTextSharp.text.pdf.PdfDocument.Add (iTextSharp.text.IElement element) [0x001d8] in <6d01038280c1418fbfdfc4080d8a4899>:0 
  at iTextSharp.text.Phrase.Process (iTextSharp.text.IElementListener listener) [0x00015] in <6d01038280c1418fbfdfc4080d8a4899>:0 
  at iTextSharp.text.pdf.PdfDocument.Add (iTextSharp.text.IElement element) [0x00549] in <6d01038280c1418fbfdfc4080d8a4899>:0 
  at iTextSharp.text.Document.Add (iTextSharp.text.IElement element) [0x00067] in <6d01038280c1418fbfdfc4080d8a4899>:0 
  at e_Beauty.Helpers.CreatePDF+<NewPDF>d__13.MoveNext () [0x00123] in C:\e-beauty\e-Beauty-master\e_Beauty\Helpers\CreatePDF.cs:52 

Nuget install fails due to missing dependency

λ Install-Package iTextSharp.LGPLv2.Core

The package(s) come(s) from a package source that is not marked as trusted.
Are you sure you want to install software from 'nuget.org'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): Y
Install-Package : Unable to find dependent package(s) (CoreCompat.System.Drawing)
At line:1 char:1

  • Install-Package iTextSharp.LGPLv2.Core
  •   + CategoryInfo          : ObjectNotFound: (CoreCompat.System.Drawing:String) [Install-Package], Exception
      + FullyQualifiedErrorId : UnableToFindDependencyPackage,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPac
     kage
    

Thank you!

Really well done! I've been playing with this today and it runs flawlessly on my .NET Core application.

I really can't thank you enough you saved me a lot of hassle with #if net452 :)

Thanks!

System.Drawing.Common dependency problem

An assembly specified in the application dependencies manifest (*.deps.json) was not found:
package: 'System.Drawing.Common', version: '4.5.0-preview1-25914-04'
path: 'lib/netcoreapp2.0/System.Drawing.Common.dll'

must removing System.Drawing.Common from *.deps.json then solved.

The libgdiplus install guide has an error on centos.

Summary of the issue

i try to create link using "ln -s /usr/local/lib/libgdiplus.so gdiplus.dll", but when i running my app,
it throws an error.
"Unhandled Exception: System.TypeInitializationException: The type initializer for 'System.DrawingCore.GDIPlus' threw an exception. ---> System.DllNotFoundException: Unable to load shared library 'gdiplus' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libgdiplus: cannot open shared object file: No such file or directory"
when i create a new link using "ln -s /usr/local/lib/libgdiplus.so libgdiplus.so" it's working fine.

Environment

The in-use version:1.5.0
Operating system: centos 7
Dotnet Core: 2.1.403

PdfPTable is throwing an Error when creating new page

Summary of the issue

When creating a new page which clones rows from the previous page I'm getting an exception from the RowSpanAbove in PdfPTable class.

Example code/Steps to reproduce:

From the looks of things this is because my header rows which I'm duplicating are using merging which causes the code to get confused. I had look in the PdfPTable class and there this line of code (Line: 1361) which checks the aboveCell isn't null and then get's the next cell.

  if (aboveCell == null)
            {
                int col = currCol - 1;
                aboveCell = aboveRow.GetCells()[col];
                while ((aboveCell == null) && (row > 0))
                    aboveCell = aboveRow.GetCells()[--col];
                return aboveCell != null && aboveCell.Rowspan > distance;
            }

This should work but clearly the while statement is checking the row hasn't gone below 0 not the column. Simple fix this while statement should be (col > 0) not row

  if (aboveCell == null)
            {
                int col = currCol - 1;
                aboveCell = aboveRow.GetCells()[col];
                while ((aboveCell == null) && (col > 0))
                    aboveCell = aboveRow.GetCells()[--col];
                return aboveCell != null && aboveCell.Rowspan > distance;
            }

Error in dotnet core

An unhandled exception has occurred while executing the request.
System.Net.WebException: No such host is known. No such host is known.
 ---> System.Net.Http.HttpRequestException: No such host is known.
 ---> System.Net.Sockets.SocketException (11001): No such host is known.
   at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean allowHttp2, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.GetHttpConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
   at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.DiagnosticsHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpClient.FinishSendAsyncUnbuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
   at System.Net.HttpWebRequest.SendRequest()
   at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
   --- End of inner exception stack trace ---
   at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
   at System.Net.WebRequest.<>c.<GetResponseAsync>b__68_2(IAsyncResult iar)
   at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---
   at iTextSharp.LGPLv2.Core.System.NetUtils.WebUtils.GetResponseStream(Uri url)
   at iTextSharp.text.Image.GetInstance(Uri url)
   at iTextSharp.text.Image.GetInstance(String filename)
   at iTextSharp.text.html.simpleparser.HtmlWorker.StartElement(String tag, Hashtable h)
   at iTextSharp.text.xml.simpleparser.SimpleXmlParser.go(TextReader reader)
   at iTextSharp.text.xml.simpleparser.SimpleXmlParser.Parse(ISimpleXmlDocHandler doc, ISimpleXmlDocHandlerComment comment, TextReader r, Boolean html)
   at iTextSharp.text.html.simpleparser.HtmlWorker.Parse(TextReader reader)
   at iTextSharp.text.html.simpleparser.HtmlWorker.ParseToList(TextReader reader, StyleSheet style, Hashtable interfaceProps)
   at AVS.WebApplicationCommon.Controllers.SharedController.DownloadTicket(Int64 orderId, Int64 ticketTemplateId)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Logged|12_1(ControllerActionInvoker invoker)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at NToastNotify.NtoastNotifyAjaxToastsMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass5_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at DNTCommon.Web.Core.AntiDosMiddleware.Invoke(HttpContext context, IOptionsSnapshot`1 antiDosConfig, IAntiDosFirewall antiDosFirewall)
   at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)
          var fileName = $"ticket{orderId}.pdf";
            var stream = new FileStream(Path.Combine(_webHostEnvironment.WebRootPath, FolderConstant.EventTickets, fileName), FileMode.Create);

            var styles = new StyleSheet();
            styles.LoadTagStyle(HtmlTags.BODY, "encoding", "Identity-H");
            styles.LoadTagStyle(HtmlTags.BODY, HtmlTags.FONT, "Tahoma");
            styles.LoadTagStyle(HtmlTags.BODY, "size", "16pt");

            var systemRoot = Environment.GetEnvironmentVariable("SystemRoot");
            FontFactory.Register(Path.Combine(systemRoot, "fonts\\tahoma.ttf"));

            var unicodeFontProvider = FontFactoryImp.Instance;
            unicodeFontProvider.DefaultEmbedding = BaseFont.EMBEDDED;
            unicodeFontProvider.DefaultEncoding = BaseFont.IDENTITY_H;

            var props = new Hashtable
            {
                { "font_factory", unicodeFontProvider }
            };

            var document = new Document();
            PdfWriter.GetInstance(document, stream);

            document.Open();
            var objects = HtmlWorker.ParseToList(new StringReader(htmlContent), styles, props);
            foreach (IElement element in objects)
            {
                document.Add(element);
            }

Retaining original Html Style

Summary of the issue

How do I retain the original style of the HTML with HtmlWorker?

Environment

.net core 2.0

The in-use version: 1.4.2
Operating system:  Windows 10
IDE: VS 2017

Example code/Steps to reproduce:

string GridHtml = '<b>This is a test</b>
                     <br/>
                     <span style='color:blue;font-size:20pt;font-family:tahoma;font-style:italic;font-weight:bold'>
                        <b>Hi<b/>
                    </span>'

TextReader sr = new StringReader(GridHtml);
                Document pdfDoc = new Document(PageSize.A3, 10f, 10f, 100f, 0f);
                PdfWriter writer = PdfWriter.GetInstance(pdfDoc, stream);
                HtmlWorker worker = new HtmlWorker(pdfDoc);
                var styles = new StyleSheet();
                var parsedHtml = HtmlWorker.ParseToList(sr, styles);
                pdfDoc.Open();
                foreach (IElement element in parsedHtml)
                {
                    pdfDoc.Add(element);
                }
                worker.Close();
                pdfDoc.Close();
                stream.Dispose();

Output:

Original styles not applied like font and color.

Attempted to read past the end of the stream.

Summary of the issue

test.pdf
This file can be previewed in the browse.But iTextSharp.LGPLv2.Core is not available.There are many files of this type.Can we solve it?

Environment

``` The in-use version: Operating system: IDE: (e.g. Visual Studio 2017) ```

Example code/Steps to reproduce:

/// <summary>
/// setWatermark
/// </summary>
/// <param name="inputfilepath"></param>
/// <param name="outputfilepath"></param>
/// <param name="waterMarkName"></param>
/// <param name="permission"></param>
public static void setWatermark(string inputfilepath, string outputfilepath, string waterMarkName)
    {
        PdfReader pdfReader = null;
        PdfStamper pdfStamper = null;
        try
        {
            pdfReader = new PdfReader(inputfilepath);
            pdfStamper = new PdfStamper(pdfReader, new FileStream(outputfilepath, FileMode.Create));
            int total = pdfReader.NumberOfPages + 1;
            iTextSharp.text.Rectangle psize = pdfReader.GetPageSize(1);
            float width = psize.Width;
            float height = psize.Height;
            PdfContentByte content;
            BaseFont font = BaseFont.CreateFont(@"C:\WINDOWS\Fonts\SIMFANG.TTF", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
            PdfGState gs = new PdfGState();
            for (int i = 1; i < total; i++)
            {
                content = pdfStamper.GetOverContent(i);                    
                gs.FillOpacity = 0.3f;
                content.SetGState(gs);
                content.BeginText();
                content.SetColorFill(BaseColor.LightGray);
                content.SetFontAndSize(font, 100);
                content.SetTextMatrix(0, 0);
                content.ShowTextAligned(Element.ALIGN_CENTER, waterMarkName, width / 2 - 50, height / 2 - 50, 55);
                content.EndText();
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            if (pdfStamper != null)
                pdfStamper.Close();
            if (pdfReader != null)
                pdfReader.Close();
        }
    }

Output:

at iTextSharp.text.pdf.RandomAccessFileOrArray.ReadFully(Byte[] b, Int32 off, Int32 len) in \src\iTextSharp.LGPLv2.Core\iTextSharp\text\pdf\RandomAccessFileOrArray.cs:line 360

Missing emoji in BaseFont.IDENTITY_H encoding

Summary of the issue

I search a lot of links in google but not found any valuable docs for it.

I want to export pdf file using ITextSharp library that contains Persian, English, Emoji and special

Environment

iTextSharp.LGPLv2.Core version: 1.6.7
.NET Core SDK version: 3.1.101
IDE: vs 2019

Example code/Steps to reproduce:

public PdfGenerator( BaseFont bf = null)
{
    _bf = bf ?? BaseFont.CreateFont(Environment.GetEnvironmentVariable("windir") + @"\fonts\iransans.ttf",
              BaseFont.IDENTITY_H, true);

}

var fontNormal = new Font(_bf, 12, Font.NORMAL, BaseColor.Black);

table.AddCell(new PdfPCell(new Phrase(12, text, fontNormal))
{
   RunDirection = PdfWriter.RUN_DIRECTION_RTL,
   BorderWidth = 0,
   Padding = 20,
   Colspan = isLongText ? 3 : 2,
   CellEvent = new RoundedBorder2()
});

It's about how to set 'BaseFont.NOT_EMBEDDED '

I created a font with <BaseFont baseFont = BaseFont.CreateFont(@"c:\windows\fonts\SIMHEI.TTF", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED)>,

but the font still embed in pdf,so i print with <baseFont.IsEmbedded()> and the result is true,so i want to konw why?

I want to get your help,thanks a lot .

How to use Chinese code with iTextAsian.dll without ttf file

I need to create a Chinese PDF file,so I use the iTextAsian.dll and my code like this:

BaseFont.AddToResourceSearch(@"app\iTextAsian.dll");
BaseFont.AddToResourceSearch(@"app\iTextAsianCmaps.dll");
BaseFont songFont = BaseFont.CreateFont("STSong-Light", "UniGB-UCS2-H",BaseFont.NOT_EMBEDDED);

But it throws an error:Font STSong-Light with UniGB-UCS2-H is not recognized.
Could you tell me what should I do?Thanks.

Compatibility of PdfStamper

Summary of the issue

When I tried to modify acrofields of a non-English pdf. I found that I cannot save the pdf file. It stuck at the PdfStamperImp.cs Line 892. The program stopped but did not throw any exception. The pdf was created from a Microsoft Word document by Phantom PDF.

Then I tried a different version of PDF, PDFs directly produced by Microsoft Word are normal. The altMetadata seemed to be different in Phantom PDF.

Environment

The in-use version:Latest version source and binary 1.3.2
Operating system: 
OS: WIN10
IDE:  Visual Studio 2017 Community 15.4

Example code/Steps to reproduce:

1. Find a PDF produced by Phantom PDF
2. Open it and call PdfStamper.Close()

Output:

Exception message:N/A
Full Stack trace:N/A

I have a big html DOM with some links, While parsing I got "invalid uri the hostname could not be parsed."

Summary of the issue

I have a big html DOM with some links, While parsing I got invalid uri the hostname could not be parsed.
Screenshot (4)

Environment

iTextSharp.LGPLv2.Core version: 
.NET Core SDK version: 2.2
IDE: Visual studio 2019

Example code/Steps to reproduce:

MemoryStream stream = new MemoryStream();
var document = new Document();
var pdfWriter = PdfWriter.GetInstance(document, stream);
document.Open();
var objects = HtmlWorker.ParseToList(
    new StringReader(html),
    null
);
foreach(IElement element in objects) {
    document.Add(element);
};
pdfWriter.Close();
document.Close();
stream.Position = 0;
return stream;

Output:

Exception message:
Full Stack trace:

Object null refrence while adding table to document

Hello. Please help!

There is too much code so here is .txt file with whole function.
function.txt

Exception:
Object reference not set to an instance of an object.

Stack:
at iTextSharp.text.pdf.PdfPTable.GetRowHeight(Int32 idx, Boolean firsttime)
at iTextSharp.text.pdf.ColumnText.GoComposite(Boolean simulate)
at iTextSharp.text.pdf.ColumnText.Go(Boolean simulate)
at iTextSharp.text.pdf.PdfDocument.AddPTable(PdfPTable ptable)
at iTextSharp.text.pdf.PdfDocument.Add(IElement element)
at iTextSharp.text.Document.Add(IElement element)
at OptimoKasiarz.Data.Classes.Methods.WydrukTest(IHostingEnvironment _hostingEnvironment, Urzedy us, Podatnicy p, UrzadzeniaPodatnika up) in C:\OptimoKasiarz\OptimoKasiarz\Data\Classes\Methods.cs:line 309

I copied this function from my older, desktop app where iTextSharp was in ver.: 5.5.9.0

convert multi Image to pdf

hi
i write this method in .net core 2 and save byte result in database:

 public byte[] ExportImagesToPdf(ICollection<IFormFile> files)
    {

      using (MemoryStream ms = new MemoryStream())
      {
        //creating a sample Document
        var pdfDoc = new Document(PageSize.A4);
        PdfWriter.GetInstance(pdfDoc, ms);
        pdfDoc.Open();
        foreach (var file in files)
        {
          using (Stream stream = file.OpenReadStream())
          {
            using (var binaryReader = new BinaryReader(stream))
            {
              var fileContent = binaryReader.ReadBytes((int) file.Length);

              var pngImg = Image.GetInstance(fileContent);

              pngImg.ScaleAbsolute(pdfDoc.PageSize.Width, pdfDoc.PageSize.Height);

              pngImg.SetAbsolutePosition(0, 0);

              //add to page
              pdfDoc.Add(pngImg);
              //start a new page
              pdfDoc.NewPage();
            }
          }
        }

        byte[] result = ms.ToArray();
        return result;
      }
    }

but when i get this byte array and download it from web , chrome pdf viewer show: "Failed to load PDF document"

Documentation.

Summary of the issue

Not really an issue, but more of a question. Is there any resources/documents, related to this particular version, so i could look up for some examples, etc ?
Thanks.

CurrentPageHeight

can you add this property in next version.
class name is iTextSharp.text.pdf.PdfWriter.
I am not able access CurrentHeight because it is protected
public float CurrentPageHeight { get { return Pdf.CurrentHeight; } }

Error when creating PDF in RowSpanAbove method

Summary of the issue

When we create a PDF in certain cases the component throws an exception:

Error Pdf System.NullReferenceException: Object reference not set to an instance of an object.
at iTextSharp.text.pdf.PdfPTable.RowSpanAbove(Int32 currRow, Int32 currCol)

Output:

Exception message: Error Pdf System.NullReferenceException: Object reference not set to an instance of an object.
Full Stack trace:
Error Pdf System.NullReferenceException: Object reference not set to an instance of an object.
   at iTextSharp.text.pdf.PdfPTable.RowSpanAbove(Int32 currRow, Int32 currCol)
   at iTextSharp.text.pdf.PdfPTable.GetRowHeight(Int32 idx, Boolean firsttime)
   at iTextSharp.text.pdf.ColumnText.GoComposite(Boolean simulate)
   at iTextSharp.text.pdf.ColumnText.Go(Boolean simulate)
   at iTextSharp.text.pdf.PdfPCell.GetMaxHeight()
   at iTextSharp.text.pdf.PdfPRow.CalculateHeights()
   at iTextSharp.text.pdf.PdfPRow.SplitRow(PdfPTable table, Int32 rowIndex, Single new_height)
   at iTextSharp.text.pdf.ColumnText.GoComposite(Boolean simulate)
   at iTextSharp.text.pdf.ColumnText.Go(Boolean simulate)
   at iTextSharp.text.pdf.PdfDocument.AddPTable(PdfPTable ptable)
   at iTextSharp.text.pdf.PdfDocument.Add(IElement element)
   at iTextSharp.text.Document.Add(IElement element)

Fix:

We cloned the project and debugged it in order to find why we're getting this error.
We found that the problem is at line 1365 of PdfPTable class:

while ((aboveCell == null) && (row > 0))
{
aboveRow = (PdfPRow)rows[--row];
aboveCell = aboveRow.GetCells()[currCol];
}

We did a modification in the while to handle aboveRow object in case it would be null:

while ((aboveCell == null) && (row > 0))
{
aboveRow = (PdfPRow)rows[--row];
if (aboveRow == null) return false;
aboveCell = aboveRow.GetCells()[currCol];
}

With this modification the component worked like a charm.

It would great if you can include this modification in the future releases of the component.
I also should mention that you did a good job porting iTextSharp to .NET core.

SimpleTextExtractionStrategy ?

Hi,

I was trying to use your project for my .NetCore app, to replace the usage of the .net 4.0 lib which I can't use.

I managed to create the PdfReader, but I can't find what would be the equivalent of PdfTextExtractor class, do you have any idea?

fonts in bold have less clarity

12452.pdf

Summary of the issue

when using fonts other than defaults,creating pdf have less clarity in case of bold letters on . It shows some shadow in letters.Sample file is attached above.

Environment

iTextSharp.LGPLv2.Core version: 1.6.1
.NET Core SDK version: 2.1.0
IDE: Visual studio 2019

Example code/Steps to reproduce:

paste your core code

Output:

Exception message:
Full Stack trace:

How to add custom css file

Summary of the issue

How to add css file

Thank you

Environment

The in-use version:
Operating system: 
Ubuntu or windows

Visual Studio 2017

Example code/Steps to reproduce:

paste your core code

 StringBuilder html = new StringBuilder();
            html.Append("<!doctype html>");
            html.Append("<html>");
            html.Append("<head>");
            html.Append("<meta http-equiv='content-type' content='text/html;charset=UTF-8'>");
            html.Append("<title>Freebird Airlines e-Bilet</title>");            
            html.Append($"<link href='file:///{basePath}\\css\\stylegib.css' rel='stylesheet' type='text/css'>");
            html.Append($"<link href='file:///{basePath}\\css\\reset.css' rel='stylesheet' type='text/css'>");
            html.Append("</head>");
            html.Append("<body>");
            html.Append("</body></html>");

            MemoryStream ms = new MemoryStream();
            TextReader txtReader = new StringReader(html.ToString());
            Document doc = new Document(PageSize.A4, 25, 25, 25, 25);
            doc.SetMargins(doc.LeftMargin, doc.RightMargin, 35, 0);
            PdfWriter pdfWriter = PdfWriter.GetInstance(doc, ms);
            doc.Open();

            HtmlWorker htmlWorker = new HtmlWorker(doc);
            htmlWorker.StartDocument();
            htmlWorker.Parse(txtReader);
            htmlWorker.EndDocument();
            htmlWorker.Close();
            doc.Close();

            var byteData = Convert.ToBase64String(ms.ToArray());


            doc.Close();

            ms.Dispose();



NullReferenceException on copy link annotation to new document

i have pdf document which contains several link annotations: some of them is external link to web site, other is link inside document
i need to create copy of this document and add watermark on each page.

so, i create PageEventHandler and add corresponded object to document with no problem. But after i copied links from source documents to copy i have NullReferenceException


for (int page = 0; page < reader.NumberOfPages; page++)
{
    var links = reader.GetLinks(page + 1).ToArray();

   foreach (PdfAnnotation.PdfImportedLink link in links)
   {
	var annotation = link.CreateAnnotation(writer);
	writer.AddAnnotation(annotation);
    }
}

document.Close(); // <--NullReferenceException here

where writer is PdfWriter for document which contains full copy of source document

exception generated with following call stack:

iTextSharp.text.pdf.PdfWriter.GetNewObjectNumber(iTextSharp.text.pdf.PdfReader reader, int number, int generation)	 	
iTextSharp.text.pdf.PrIndirectReference.ToPdf(iTextSharp.text.pdf.PdfWriter writer, System.IO.Stream os)
iTextSharp.text.pdf.PdfArray.ToPdf(iTextSharp.text.pdf.PdfWriter writer, System.IO.Stream os)
iTextSharp.text.pdf.PdfDictionary.ToPdf(iTextSharp.text.pdf.PdfWriter writer, System.IO.Stream os)
iTextSharp.text.pdf.PdfIndirectObject.WriteTo(System.IO.Stream os)
iTextSharp.text.pdf.PdfWriter.PdfBody.Add(iTextSharp.text.pdf.PdfObject objecta, int refNumber, bool inObjStm)	
iTextSharp.text.pdf.intern.PdfAnnotationsImp.RotateAnnotations(iTextSharp.text.pdf.PdfWriter writer, iTextSharp.text.Rectangle pageSize)	
iTextSharp.text.pdf.PdfDocument.NewPage()
...

after searching by this problem i found only one thread on forum (http://itext.2136553.n4.nabble.com/Null-pointer-exception-in-PdfWriter-td2313742.html) with suggested workaround. but i didn't find this patch in any forks of itestsharp, so i don't think that this is correct way.

Environment

iTextSharp.LGPLv2.Core version:  1.6.5
.NET Core SDK version: 2.1
IDE: vs 2019

Problem in Image

HI I am using this in my mvc core 2.0 application but image is not shown in pdf. Image code shown Below:-

var logoImage = iTextSharp.text.Image.GetInstance("LogoImagepath");
               var logoImgCell = new PdfPCell
               {
                   Colspan = 2,
                   Border = 0,
                   HorizontalAlignment = Element.ALIGN_RIGHT
               };
               logoImage.WidthPercentage = 60;
               logoImage.Alignment = Element.ALIGN_RIGHT;
               logoImgCell.AddElement(logoImage);
               outerTable.AddCell(logoImgCell);

Please help

Encoding problem with extracted text from Ghostscript generated pdf

Summary of the issue

Hi there,

We've been using this library for a long time now in order to extract text from pdfs. However, since we've switched methods for generating the input pdfs, the resulting extracted text is nothing but gibberish. To me it looks like an interesting encoding problem :)

I've compared the extracted text with another pdf library called PdfPig which extracts the text as expected. However, for performance reasons, iTextSharp is still the prefered option.

To debug the problem, I've looked at the differences in the tokenization code. Here you can find it in the alternative implementation. Certain parts look very familiar, but I noticed that PdfPig also corrects for endianness. I've reimplemented that in the PrTokenizer, but that didn't seem to be the solution.

We would really appreciate it if you could help us find a solution. Thanks!

Environment

The in-use version: 1.5.1
Operating system: Windows
IDE: VS2019

Example code/Steps to reproduce:

  • sample-original.pdf This is the original file, where text extraction works in both methods.
  • sample-recostar.pdf This is the file after it's gone through OCR software (I think it uses Ghostscript to generate the pdf).
class Program
    {
        static void Main(string[] args)
        {
            var fileNames = new[]
            {
                "sample-original.pdf",
                "sample-recostar.pdf"
            };

            ExtractWithItext(fileNames);
            ExtractWithPdfPig(fileNames);

            Console.ReadLine();
        }

        public static void ExtractWithItext(IEnumerable<string> fileNames)
        {
            Console.WriteLine($"ITEXT");
            foreach (var fileName in fileNames)
            {
                var reader = new iTextSharp.text.pdf.PdfReader(fileName);

                Console.WriteLine($"OUTPUT {fileName}: ");

                var content = reader.GetPageContent(1);

                var tokenizer = new iTextSharp.text.pdf.PrTokeniser(new iTextSharp.text.pdf.RandomAccessFileOrArray(content));
                while (tokenizer.NextToken())
                {
                    if (tokenizer.TokenType == iTextSharp.text.pdf.PrTokeniser.TK_STRING)
                    {
                        Console.Write(tokenizer.StringValue);
                    }
                }

                Console.WriteLine();
            }
        }

        private static void ExtractWithPdfPig(IEnumerable<string> fileNames)
        {
            Console.WriteLine($"PDFPIG");
            foreach (var fileName in fileNames)
            {
                Console.WriteLine($"OUTPUT {fileName}: ");
                using(var stream = File.OpenRead(fileName))
                using (UglyToad.PdfPig.PdfDocument document = UglyToad.PdfPig.PdfDocument.Open(stream))
                {
                    var page = document.GetPage(1);

                    string fullText = string.Join(" ", page.GetWords());

                    Console.WriteLine(fullText);
                    Console.WriteLine();
                }
            }
        }
    }

Output:

Notice that using iTextSharp in combination with sample-recostar.pdf results in nonesense, while the same file with PdfPig results in the expected text.

ITEXT
OUTPUT sample-original.pdf:
 A Simple PDF File  This is a small demonstration .pdf file -  just for use in the Virtual Mechanics tutorials. More text. And more  text. And more text. And more text. And more text.  And more text. And more text. And more text. And more text. And more  text. And more text. Boring, zzzzz. And more text. And more text. And  more text. And more text. And more text. And more text. And more text.  And more text. And more text.  And more text. And more text. And more text. And more text. And more  text. And more text. And more text. Even more. Continued on page 2 ...
OUTPUT sample-recostar.pdf:
 � � � � � �  �
 � � � � � � � � � � � � �  � � �  � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �


PDFPIG
OUTPUT sample-original.pdf:
A Simple PDF File This is a small demonstration .pdf file - just for use in the Virtual Mechanics tutorials. More text. And more text. And more text. And more text. And more text. And more text. And more text. And more text. And more text. And more text. And more text. Boring, zzzzz. And more text. And more text. And more text. And more text. And more text. And more text. And more text. And more text. And more text. And more text. And more text. And more text. And more text. And more text. And more text. And more text. Even more. Continued on page 2 ...

OUTPUT sample-recostar.pdf:
A Simple PDF File This is a small demonstration .pdf file - just for use in the Virtual Mechanics tutorials. More text. And more text. And more text. And more text. And more text. And more text. And more text. And more text. And more text. And more text. And more text. Boring, zzzzz. And more text. And more text. And more text. And more text. And more text. And more text. And more text. And more text. And more text. And more text. And more text. And more text. And more text. And more text. And more text. And more text. Even more. Continued on page 2...

PdfContentByte.ShowTextAligned rotation is ignored

There is a bug in PdfContentByte.showTextAligned method. It goes like this:

if (rotation.ApproxNotEqual(0)) {
    // branch which assumes rotation is 0    
}
else {
    // branch which assumes rotation is not 0
}

So rotation is effictively ignored, because branches are switched. Changing that to

if (rotation.ApproxEquals(0)) {

} else {

}

fixes the issue.

Strong name missing warning

Summary of the issue

When used in VS2017 and Nuget after rebuild it warn:

Severity Code Description Project File Line Suppression State
Warning CS8002 Referenced assembly 'iTextSharp.LGPLv2.Core, Version=1.4.4.0, Culture=neutral, PublicKeyToken=null' does not have a strong name. Sestavy D:\Pracovni\git-repos\Lezeni-Core\Sestavy\CSC 1 Active

It is possible build it with strong name. We want replace are locally referenced downloade original dll with nuget version and in future switch to .netstandard and core.

Thanks for answer and migration of this LGPL version.

PdfTextExtractor

Hello! I'm currently using itextsharp 5.+ on my application, but I would like to port it to work in ASP.NET Core 2.0. The functionality I'm using right now is provided by PdfTextExtractor and related classes.

By now, the only migration project I've found is this, but it's 4.x. Do you have plans to upgrade it?

Thanks!

Newlines being ignored

Summary of the issue

I cannot get text to manually break to a new line within "columnText.SetSimpleColumn" I have added a new chunk with just "\n" in it, I have manually stripped out "\n" from my text and added a Chunk.NewLine, it seems to be ignoring my \n and any attempt to break onto a new line. The break characters are not displayed however, so they are being stripped out or processed somehow.

All my text is wrapping on top of itself as well. While it's unreadable, it might be 'breaking' but not moving down a line, however I can't find a way to fix it.

Environment

The in-use version: v1.5.0
Operating system: macOS
IDE: Visual Studio Code
Language: C# / dotnet core 2.2

Example code/Steps to reproduce:

NB: the unicode chars "\u00A0" are added to add a space before/after the text that doesn't get stripped out, but with/without this is makes no difference.

var ct = new ColumnText(cb);
var paragraph = new Paragraph();

var listofstrings = new List<string>();
listofstrings.Add("Some text that should \n break there \n and here");
foreach (var astring in listofstrings)
{
    var chunk = new Chunk($"\u00A0{astring}\u00A0", font);
    paragraph.Add(chunk);
}

ct.SetSimpleColumn(paragraph, ll_x, ll_y, ur_x, ur_y, 0, textElement.TextAlignment);
var status = ct.Go();

Output:

Screenshot 2019-05-09 at 16 35 27

As you can see in the above picture, the text just wraps ontop of itself.

Any support for fdfWriter.SetFieldAsImage() ?

Summary of the issue

Previously in iTextSharp we were able to add images for image fields in FdfWriter like so:

//Add barcode image
Image img = Image.GetInstance(barcode_jpg);
fdfWriter.SetFieldAsImage("Barcode", img);
fdfWriter.Write();

Is there a way to do this with the .Net Core port that i am not seeing?
Thanks in advance.

Environment

iTextSharp.LGPLv2.Core version: 
.NET Core SDK version: 
IDE: Rider

Khmer Unicode is not rendering properly

I follow the step to create pdf succesfully and dispalyed the khmer text . but not proper rendering. And Lost English text.

Screen Shot 2020-10-09 at 2 31 10 PM

private Font GetFont(string fontNameWithExtension, int fontSize = 12)
      {
          // string fontLocation = $"{Directory.GetCurrentDirectory()}{"/wwwwroot/fonts/" + fontNameWithExtension}";
          string path = _webHostEnviroment.WebRootPath + "/fonts";
          string fontPath = Path.Combine(path, fontNameWithExtension);

          iTextSharp.text.FontFactory.Register(fontPath);

          BaseFont bf = BaseFont.CreateFont(fontPath, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
          Font f = new Font(bf, fontSize);
          


          return f;
      }

Embedded '\' in path breaks tests on macOS/Linux

Summary of the issue

Environment

The in-use version: 
Operating system: macOS/linux
IDE: (e.g. Visual Studio 2015) command line`dotnet test`

$ dotnet --info
.NET Command Line Tools (2.1.202)

Product Information:
 Version:            2.1.202
 Commit SHA-1 hash:  281caedada

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.13
 OS Platform: Darwin
 RID:         osx.10.13-x64
 Base Path:   /usr/local/share/dotnet/sdk/2.1.202/

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.9
  Build    : 1632fa1589b0eee3277a8841ce1770e554ece037

Example code/Steps to reproduce:

dotent test will throw an exception because of windows '\' directory separator characters.

 Test method iTextSharp.LGPLv2.Core.FunctionalTests.XmlITextTests.Verify_iTextXML_To_PDF_File_CanBeCreated threw exception: 
System.IO.DirectoryNotFoundException: Could not find a part of the path '/Users/breiter/src/vahidn/iTextSharp.LGPLv2.Core/src/iTextSharp.LGPLv2.Core.FunctionalTests/iTextExamples\resources\img/hitchcock.png'.

Solution: replace "iTextExamples\resources\img" with individual strings for each directory name and allow Path.Combine() to choose the appropriate Path.DirectorySeparatorChar for the OS.

diff --git a/src/iTextSharp.LGPLv2.Core.FunctionalTests/XmlITextTests.cs b/src/iTextSharp.LGPLv2.Core.FunctionalTests/XmlITextTests.cs
index bb456da..c36d059 100644
--- a/src/iTextSharp.LGPLv2.Core.FunctionalTests/XmlITextTests.cs
+++ b/src/iTextSharp.LGPLv2.Core.FunctionalTests/XmlITextTests.cs
@@ -16,7 +16,7 @@ namespace iTextSharp.LGPLv2.Core.FunctionalTests
 		[TestMethod]
 		public void Verify_iTextXML_To_PDF_File_CanBeCreated()
 		{
-			var img = Path.Combine(TestUtils.GetBaseDir(), @"iTextExamples\resources\img", "hitchcock.png");
+			var img = Path.Combine(TestUtils.GetBaseDir(), "iTextExamples", "resources", "img", "hitchcock.png");
 			var iTextXML = $@"
 <itext creationdate='1395/06/14' producer='iTextSharp.LGPLv2.Core'>
 	
@@ -57,7 +57,7 @@ namespace iTextSharp.LGPLv2.Core.FunctionalTests
 		[TestMethod]
 		public void Verify_iTextXML_CanBeParsed()
 		{
-			var img = Path.Combine(TestUtils.GetBaseDir(), @"iTextExamples\resources\img", "hitchcock.png");
+			var img = Path.Combine(TestUtils.GetBaseDir(), "iTextExamples", "resources", "img", "hitchcock.png");
 			var iTextXML = $@"
 <itext creationdate='Thu Jun 26 14:25:52 CEST 2003' producer='iTextXML by lowagie.com'>
 	<paragraph leading='18.0' font='unknown' align='Default'>

With this patch, it works.

[master] $ dotnet test src/iTextSharp.LGPLv2.Core.FunctionalTests/
Build started, please wait...
Build completed.

Test run for /Users/breiter/src/vahidn/iTextSharp.LGPLv2.Core/src/iTextSharp.LGPLv2.Core.FunctionalTests/bin/Debug/netcoreapp2.0/iTextSharp.LGPLv2.Core.FunctionalTests.dll(.NETCoreApp,Version=v2.0)
Microsoft (R) Test Execution Command Line Tool Version 15.7.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...

Total tests: 72. Passed: 72. Failed: 0. Skipped: 0.
Test Run Successful.
Test execution time: 2.9067 Seconds

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.