Skip to content

Commit

Permalink
Switched to sharpPDF
Browse files Browse the repository at this point in the history
Using sharpPDF 1.3.1 which is under LGPL instead of iTextSharp for PDF
rendering

http://sourceforge.net/projects/sharppdf/files/sharppdf/sharppdf%201.3.1/
  • Loading branch information
imclem committed Dec 23, 2014
1 parent 76cf6a3 commit ac837d6
Show file tree
Hide file tree
Showing 17 changed files with 19 additions and 51 deletions.
Binary file modified Exporting_Demo_website/Bin/Tek4.Highcharts.Exporting.dll
Binary file not shown.
Binary file modified Exporting_Demo_website/Bin/Tek4.Highcharts.Exporting.pdb
Binary file not shown.
Binary file added Exporting_Demo_website/Bin/sharpPDF.dll
Binary file not shown.
Binary file added Tek4.Highcharts.Exporting.suo
Binary file not shown.
56 changes: 7 additions & 49 deletions Tek4.Highcharts.Exporting/Exporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ namespace Tek4.Highcharts.Exporting
using System.IO;
using System.Text;
using System.Web;
using iTextSharp.text;
using iTextSharp.text.pdf;
using Svg;
using Svg.Transforms;
using System.Xml;
using sharpPDF;
using System.Drawing;

/// <summary>
/// .NET chart exporting class for Highcharts JS JavaScript charts.
Expand Down Expand Up @@ -224,54 +224,12 @@ internal void WriteToStream(Stream outputStream)

case "application/pdf":
SvgDocument svgDoc = CreateSvgDocument();
Bitmap bmp = svgDoc.Draw();

// Create PDF document.
using (Document pdfDoc = new Document())
{
// Scalar to convert from 72 dpi to 150 dpi.
float dpiScalar = 150f / 72f;

// Set page size. Page dimensions are in 1/72nds of an inch.
// Page dimensions are scaled to boost dpi and keep page
// dimensions to a smaller size.
pdfDoc.SetPageSize(new Rectangle(
svgDoc.Width / dpiScalar,
svgDoc.Height / dpiScalar));

// Set margin to none.
pdfDoc.SetMargins(0f, 0f, 0f, 0f);

// Create PDF writer to write to response stream.
using (PdfWriter pdfWriter = PdfWriter.GetInstance(
pdfDoc,
outputStream))
{
// Configure PdfWriter.
pdfWriter.SetPdfVersion(PdfWriter.PDF_VERSION_1_5);
pdfWriter.CompressionLevel = PdfStream.DEFAULT_COMPRESSION;

// Add meta data.
pdfDoc.AddCreator(PdfMetaCreator);
pdfDoc.AddTitle(this.Name);

// Output PDF document.
pdfDoc.Open();
pdfDoc.NewPage();

// Create image element from SVG image.
Image image = Image.GetInstance(svgDoc.Draw(), ImageFormat.Bmp);
image.CompressionLevel = PdfStream.DEFAULT_COMPRESSION;

// Must match scaling performed when setting page size.
image.ScalePercent(100f / dpiScalar);

// Add image element to PDF document.
pdfDoc.Add(image);

pdfDoc.CloseDocument();
}
}

pdfDocument doc = new pdfDocument(this.Name, null);
pdfPage page = doc.addPage(bmp.Height, bmp.Width);
page.addImage(bmp, 0, 0);
doc.createPDF(outputStream);
break;

case "image/svg+xml":
Expand Down
7 changes: 5 additions & 2 deletions Tek4.Highcharts.Exporting/Tek4.Highcharts.Exporting.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="itextsharp, Version=5.1.3.0, Culture=neutral, PublicKeyToken=8354ae6d2174ddca, processorArchitecture=MSIL" />
<Reference Include="sharpPDF, Version=1.0.1723.37634, Culture=neutral">
<SpecificVersion>False</SpecificVersion>
<HintPath>ThirdParty\sharpPDF.dll</HintPath>
</Reference>
<Reference Include="Svg, Version=1.5.2.33180, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>ThirdParty\Svg.dll</HintPath>
Expand All @@ -75,7 +78,7 @@
</Compile>
</ItemGroup>
<ItemGroup>
<Content Include="ThirdParty\itextsharp.dll" />
<Content Include="ThirdParty\sharpPDF.dll" />
<Content Include="ThirdParty\Svg.dll" />
</ItemGroup>
<ItemGroup>
Expand Down
Empty file modified Tek4.Highcharts.Exporting/ThirdParty/Svg.dll
100755 → 100644
Empty file.
Binary file not shown.
Binary file added Tek4.Highcharts.Exporting/bin/Debug/Svg.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
D:\Clem\Documents\Projets\Highcharts-export-module-asp.net\Tek4.Highcharts.Exporting\obj\Debug\Tek4.Highcharts.Exporting.csprojResolveAssemblyReference.cache
D:\Clem\Documents\Projets\Highcharts-export-module-asp.net\Tek4.Highcharts.Exporting\bin\Debug\Tek4.Highcharts.Exporting.dll
D:\Clem\Documents\Projets\Highcharts-export-module-asp.net\Tek4.Highcharts.Exporting\bin\Debug\Tek4.Highcharts.Exporting.pdb
D:\Clem\Documents\Projets\Highcharts-export-module-asp.net\Tek4.Highcharts.Exporting\bin\Debug\sharpPDF.dll
D:\Clem\Documents\Projets\Highcharts-export-module-asp.net\Tek4.Highcharts.Exporting\bin\Debug\Svg.dll
D:\Clem\Documents\Projets\Highcharts-export-module-asp.net\Tek4.Highcharts.Exporting\obj\Debug\Tek4.Highcharts.Exporting.dll
D:\Clem\Documents\Projets\Highcharts-export-module-asp.net\Tek4.Highcharts.Exporting\obj\Debug\Tek4.Highcharts.Exporting.pdb
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit ac837d6

Please sign in to comment.