Skip to content

Commit

Permalink
Resolve merge with master and PDFA implementation.
Browse files Browse the repository at this point in the history
(cherry picked from commit 404a2f9)

# Conflicts:
#	dotnet/src/dotnetframework/GxPdfReportsCS/PDFReportCommon.cs
#	dotnet/src/dotnetframework/GxPdfReportsCS/PDFReportItext4.cs
  • Loading branch information
claudiamurialdo committed Sep 20, 2023
1 parent 4703030 commit cc23a48
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 29 deletions.
60 changes: 54 additions & 6 deletions dotnet/src/dotnetcore/GxPdfReportsCS/PDFReportItext7.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,28 +94,50 @@ protected override void init(ref int gxYPage, ref int gxXPage, int pageWidth, in
else
justifiedType = TextAlignment.JUSTIFIED;

writer = new PdfWriter(outputStream);
writer = new PdfWriter(outputStream);
writer.SetCompressionLevel(CompressionConstants.BEST_COMPRESSION);
try
{
string level = props.getGeneralProperty(Const.COMPLIANCE_LEVEL);
if (Enum.TryParse(level, true, out complianceLevel))
{
//if (SetComplainceLevel(complianceLevel))
//writer.SetTagged();
}

pdfDocument = new PdfDocument(writer);
pdfDocument.SetDefaultPageSize(this.pageSize);
document = new Document(pdfDocument);


}
catch (PdfException de)
{
GXLogging.Debug(log, "GxDrawRect error", de);
}
}

internal override bool SetComplainceLevel(PdfConformanceLevel level)
{
/*switch (level)
{
case PdfConformanceLevel.Pdf_A1A:
writer.PDFXConformance = PdfWriter.PDFA1A;
return true;
case PdfConformanceLevel.Pdf_A1B:
writer.PDFXConformance = PdfWriter.PDFA1B;
return true;
default:
return false;
}*/
return false;
}

/**
* @param hideCorners indicates whether corner triangles should be hidden when the side that joins them is hidden.
*/

/**
* @param hideCorners indicates whether corner triangles should be hidden when the side that joins them is hidden.
*/

private void drawRectangle(PdfCanvas cb, float x, float y, float w, float h,
private void drawRectangle(PdfCanvas cb, float x, float y, float w, float h,
int styleTop, int styleBottom, int styleRight, int styleLeft,
float radioTL, float radioTR, float radioBL, float radioBR, float penAux, bool hideCorners)
{
Expand Down Expand Up @@ -505,6 +527,7 @@ public override void GxDrawBitMap(String bitmap, int left, int top, int right, i
image.ScaleAbsolute(rightAux - leftAux, bottomAux - topAux);
else
image.ScaleToFit(rightAux - leftAux, bottomAux - topAux);
image.GetAccessibilityProperties().SetAlternateDescription(Path.GetFileName(bitmap));
document.Add(image);
}
}
Expand Down Expand Up @@ -671,8 +694,17 @@ public override void GxAttris(String fontName, int fontSize, bool fontBold, bool
baseFont = CreateDefaultFont();
}
}
PdfFont defaultFont;
private PdfFont CreateDefaultFont()
{
if (defaultFont == null)
{
if (IsPdfA())
defaultFont = PdfFontFactory.CreateFont("Helvetica", PdfEncodings.CP1252, PdfFontFactory.EmbeddingStrategy.PREFER_NOT_EMBEDDED);
else
defaultFont = PdfFontFactory.CreateFont("Helvetica", PdfEncodings.WINANSI, PdfFontFactory.EmbeddingStrategy.PREFER_NOT_EMBEDDED);
}

return PdfFontFactory.CreateFont("Helvetica", PdfEncodings.WINANSI, PdfFontFactory.EmbeddingStrategy.PREFER_NOT_EMBEDDED);
}
public override void setAsianFont(String fontName, String style)
Expand Down Expand Up @@ -1235,6 +1267,22 @@ public override void GxEndDocument()
pdfDocument.GetCatalog().SetOpenAction(PdfAction.CreateJavaScript(javascript.ToString()));
}

if (IsPdfA())
{
/*using (Stream iccProfile = ReadResource("sRGB Color Space Profile.icm"))
{
ICC_Profile icc = ICC_Profile.GetInstance(iccProfile);
writer.SetOutputIntents("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", icc);
}
writer.ExtraCatalog.Put(PdfName.LANG, new PdfString(Config.GetCultureForLang(language).Name));
PdfDictionary markInfo = new PdfDictionary(PdfName.MARKINFO);
markInfo.Put(PdfName.MARKED, new PdfBoolean(PdfBoolean.TRUE));
writer.ExtraCatalog.Put(PdfName.MARKINFO, markInfo);
writer.CreateXmpMetadata();*/

}
document.Close();


Expand Down
40 changes: 21 additions & 19 deletions dotnet/src/dotnetframework/GxPdfReportsCS/PDFReportCommon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,8 @@ internal enum VerticalAlign
MIDDLE = 1,
BOTTOM = 2,
}
public enum PdfConformanceLevel
{
None,
Pdf_A1B,
Pdf_X1A2001,
Pdf_A1A,
Pdf_A2A,
Pdf_A2B,
Pdf_A3A,
Pdf_A3B
}
public class PDFReportItextBase : IReportHandler

public abstract class PDFReportItextBase : IReportHandler
{
protected int lineHeight, pageLines;

Expand All @@ -51,8 +41,7 @@ public class PDFReportItextBase : IReportHandler
protected bool fontStrikethru;
protected int fontSize;
protected string language;
protected PdfConformanceLevel complianceLevel = PdfConformanceLevel.None;


protected Stream outputStream = null;

protected static object syncRoot = new Object();
Expand Down Expand Up @@ -89,6 +78,7 @@ public class PDFReportItextBase : IReportHandler
public static float DOTS_UNITS_ON = 1;
public bool lineCapProjectingSquare = true;
public bool barcode128AsImage = true;
protected PdfConformanceLevel complianceLevel = PdfConformanceLevel.None;
protected float[] STYLE_SOLID = new float[] { 1, 0 };//0
protected float[] STYLE_NONE = null;//1
protected float[] STYLE_DOTTED, //2
Expand Down Expand Up @@ -309,7 +299,7 @@ private void loadPrinterSettingsProps(String iniFile, String form, String printe
}
internal static void SetDefaultComplianceLevel(PdfConformanceLevel level)
{
if (props != null)
if (props!=null)
props.setGeneralProperty(Const.COMPLIANCE_LEVEL, level.ToString());
}
private void loadProps()
Expand Down Expand Up @@ -349,7 +339,7 @@ private void loadProps()
props.setupGeneralProperty(Const.MARGINS_INSIDE_BORDER, Const.DEFAULT_MARGINS_INSIDE_BORDER.ToString().ToLower());
props.setupGeneralProperty(Const.OUTPUT_FILE_DIRECTORY, ".");
props.setupGeneralProperty(Const.LEADING, "2");
props.setupGeneralProperty(Const.COMPLIANCE_LEVEL, PdfConformanceLevel.None.ToString());
props.setupGeneralProperty(Const.COMPLIANCE_LEVEL, PdfConformanceLevel.None.ToString());
props.setupGeneralProperty(Const.RUN_DIRECTION, Const.RUN_DIRECTION_LTR);
props.setupGeneralProperty(Const.JUSTIFIED_TYPE_ALL, "false");

Expand Down Expand Up @@ -719,6 +709,7 @@ protected bool IsPdfA()
{
return complianceLevel != 0;
}

public void GxEndPrinter()
{
}
Expand Down Expand Up @@ -906,8 +897,9 @@ protected float reconvertScale(float value)
{
float result = value / (float)(SCALE_FACTOR / PPP);
return result;
}
}

internal abstract bool SetComplainceLevel(PdfConformanceLevel level);
}

public class ParseINI
Expand Down Expand Up @@ -1359,7 +1351,7 @@ public class Const
public static String ADJUST_TO_PAPER = "AdjustToPaper"; //fit to page
public static String LINE_CAP_PROJECTING_SQUARE = "LineCapProjectingSquare";
public static String BARCODE128_AS_IMAGE = "Barcode128AsImage";
public static String LEADING = "Leading";
public static String LEADING = "Leading";
internal static String COMPLIANCE_LEVEL = "ComplianceLevel";

//Printer settings
Expand Down Expand Up @@ -1850,6 +1842,16 @@ public static ArrayList parseLine(String line, String separator)
}

}

public enum PdfConformanceLevel
{
None,
Pdf_A1B,
Pdf_X1A2001,
Pdf_A1A,
Pdf_A2A,
Pdf_A2B,
Pdf_A3A,
Pdf_A3B
}
}

9 changes: 5 additions & 4 deletions dotnet/src/dotnetframework/GxPdfReportsCS/PDFReportItext4.cs
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ private BaseFont CreateDefaultFont()
else
defaultFont = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
}
return defaultFont;
return defaultFont;
}
private void LoadAsianFontsDll()
{
Expand Down Expand Up @@ -1401,7 +1401,6 @@ public override void GxEndDocument()
}

}

if (IsPdfA())
{
using (Stream iccProfile = ReadResource("sRGB Color Space Profile.icm"))
Expand All @@ -1417,7 +1416,8 @@ public override void GxEndDocument()

writer.CreateXmpMetadata();

}
}

document.Close();


Expand Down Expand Up @@ -1532,7 +1532,8 @@ private void SetSimpleColumn(ColumnText col, Rectangle rect)
{
col.SetSimpleColumn(rect.Left, rect.Bottom, rect.Right, rect.Top);
}
internal bool SetComplainceLevel(PdfConformanceLevel level)

internal override bool SetComplainceLevel(PdfConformanceLevel level)
{
switch (level)
{
Expand Down

0 comments on commit cc23a48

Please sign in to comment.