Set PDF fonts to be embedded.
This commit is contained in:
parent
4abeb80fb4
commit
48960152ac
@ -1296,8 +1296,7 @@ namespace Volian.Print.Library
|
|||||||
total.BoundingBox = new Rectangle(-20, -20, 100, 100);
|
total.BoundingBox = new Rectangle(-20, -20, 100, 100);
|
||||||
//try
|
//try
|
||||||
//{
|
//{
|
||||||
helv = BaseFont.CreateFont(BaseFont.HELVETICA,
|
helv = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.EMBEDDED);
|
||||||
BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
|
|
||||||
//}
|
//}
|
||||||
//catch (Exception)
|
//catch (Exception)
|
||||||
//{
|
//{
|
||||||
|
@ -243,6 +243,7 @@ namespace Volian.Print.Library
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
writer = PdfWriter.GetInstance(document, new FileStream(outputFileName, FileMode.Create));
|
writer = PdfWriter.GetInstance(document, new FileStream(outputFileName, FileMode.Create));
|
||||||
|
writer.PDFXConformance = PdfWriter.PDFA1B;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -790,7 +791,7 @@ namespace Volian.Print.Library
|
|||||||
if (textLayer != null) cb.BeginLayer(textLayer);
|
if (textLayer != null) cb.BeginLayer(textLayer);
|
||||||
float fontSize = 30;
|
float fontSize = 30;
|
||||||
ColumnText ct = new ColumnText(cb);
|
ColumnText ct = new ColumnText(cb);
|
||||||
iTextSharp.text.Font font = FontFactory.GetFont("Arial", fontSize, new iTextSharp.text.Color(PrintOverride.TextColor));
|
iTextSharp.text.Font font = FontFactory.GetFont("Arial", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, fontSize,iTextSharp.text.Font.NORMAL, new iTextSharp.text.Color(PrintOverride.TextColor));
|
||||||
Chunk chk = new Chunk(message, font);
|
Chunk chk = new Chunk(message, font);
|
||||||
float xCenter = cb.PdfDocument.PageSize.Width / 2;
|
float xCenter = cb.PdfDocument.PageSize.Width / 2;
|
||||||
float yCenter = cb.PdfDocument.PageSize.Height / 2;
|
float yCenter = cb.PdfDocument.PageSize.Height / 2;
|
||||||
|
@ -165,7 +165,7 @@ namespace Volian.Print.Library
|
|||||||
{
|
{
|
||||||
ColumnText ct = new ColumnText(cb);
|
ColumnText ct = new ColumnText(cb);
|
||||||
ct.SetSimpleColumn(left, 4 + top - yDescent, right, top - yDescent - 50);
|
ct.SetSimpleColumn(left, 4 + top - yDescent, right, top - yDescent - 50);
|
||||||
iTextSharp.text.Font font = FontFactory.GetFont("Arial", 2);
|
iTextSharp.text.Font font = FontFactory.GetFont("Arial", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 2);
|
||||||
Chunk chk = new Chunk(debugText + string.Format(" Top = {0}",top), font);
|
Chunk chk = new Chunk(debugText + string.Format(" Top = {0}",top), font);
|
||||||
Phrase ph = new Phrase(chk);
|
Phrase ph = new Phrase(chk);
|
||||||
ct.AddElement(ph);
|
ct.AddElement(ph);
|
||||||
|
@ -69,7 +69,7 @@ namespace Volian.Print.Library
|
|||||||
public void WatermarkPageNumber(int pageNumber)
|
public void WatermarkPageNumber(int pageNumber)
|
||||||
{
|
{
|
||||||
Rectangle pageSize = ContentByte.PdfWriter.PageSize; // Get page size
|
Rectangle pageSize = ContentByte.PdfWriter.PageSize; // Get page size
|
||||||
BaseFont myBasefont = BaseFont.CreateFont(BaseFont.HELVETICA_BOLD, Encoding.ASCII.EncodingName, false);
|
BaseFont myBasefont = BaseFont.CreateFont(BaseFont.HELVETICA_BOLD, Encoding.ASCII.EncodingName, BaseFont.EMBEDDED);
|
||||||
string strPage = pageNumber.ToString();
|
string strPage = pageNumber.ToString();
|
||||||
float h = myBasefont.GetAscentPoint(strPage, 10);
|
float h = myBasefont.GetAscentPoint(strPage, 10);
|
||||||
float w = myBasefont.GetWidthPoint(strPage, 10);
|
float w = myBasefont.GetWidthPoint(strPage, 10);
|
||||||
@ -119,7 +119,7 @@ namespace Volian.Print.Library
|
|||||||
public static iTextSharp.text.Font GetFont(string fontName, float fontSize, int fontStyle, Color fontColor)
|
public static iTextSharp.text.Font GetFont(string fontName, float fontSize, int fontStyle, Color fontColor)
|
||||||
{
|
{
|
||||||
RegisterFont(fontName);
|
RegisterFont(fontName);
|
||||||
return iTextSharp.text.FontFactory.GetFont(fontName, BaseFont.IDENTITY_H, true, fontSize, fontStyle, fontColor);
|
return iTextSharp.text.FontFactory.GetFont(fontName, BaseFont.IDENTITY_H, BaseFont.EMBEDDED, fontSize, fontStyle, fontColor);
|
||||||
}
|
}
|
||||||
public static void RegisterFont(string fontName)
|
public static void RegisterFont(string fontName)
|
||||||
{
|
{
|
||||||
|
@ -359,7 +359,7 @@ namespace Volian.Print.Library
|
|||||||
cb.BeginLayer(debugLayer);
|
cb.BeginLayer(debugLayer);
|
||||||
ColumnText ct = new ColumnText(cb);
|
ColumnText ct = new ColumnText(cb);
|
||||||
ct.SetSimpleColumn(left, top, left+50, top - 50);
|
ct.SetSimpleColumn(left, top, left+50, top - 50);
|
||||||
iTextSharp.text.Font font = FontFactory.GetFont("Arial", 2);
|
iTextSharp.text.Font font = FontFactory.GetFont("Arial", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 2);
|
||||||
Chunk chk = new Chunk(DebugId.ToString(), font);
|
Chunk chk = new Chunk(DebugId.ToString(), font);
|
||||||
Phrase ph = new Phrase(chk);
|
Phrase ph = new Phrase(chk);
|
||||||
ct.AddElement(ph);
|
ct.AddElement(ph);
|
||||||
|
@ -206,12 +206,12 @@ namespace Volian.Svg.Library
|
|||||||
public static iTextSharp.text.Font GetFont(string fontName)
|
public static iTextSharp.text.Font GetFont(string fontName)
|
||||||
{
|
{
|
||||||
RegisterFont(fontName);
|
RegisterFont(fontName);
|
||||||
return FontFactory.GetFont(fontName);
|
return FontFactory.GetFont(fontName, BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 10);
|
||||||
}
|
}
|
||||||
public static iTextSharp.text.Font GetFont(string fontName, float size, int style, System.Drawing.Color color)
|
public static iTextSharp.text.Font GetFont(string fontName, float size, int style, System.Drawing.Color color)
|
||||||
{
|
{
|
||||||
RegisterFont(fontName);
|
RegisterFont(fontName);
|
||||||
return FontFactory.GetFont(fontName, size, style, new iTextSharp.text.Color(color));
|
return FontFactory.GetFont(fontName, BaseFont.IDENTITY_H, BaseFont.EMBEDDED, size, style, new iTextSharp.text.Color(color));
|
||||||
}
|
}
|
||||||
public static void RegisterFont(string fontName)
|
public static void RegisterFont(string fontName)
|
||||||
{
|
{
|
||||||
@ -603,7 +603,7 @@ namespace Volian.Svg.Library
|
|||||||
//{
|
//{
|
||||||
// //iTextSharp.text.FontFactory.RegisterDirectories();
|
// //iTextSharp.text.FontFactory.RegisterDirectories();
|
||||||
//}
|
//}
|
||||||
iTextSharp.text.Font font = FontFactory.GetFont(Font.Name, BaseFont.IDENTITY_H, true, fontSize, fontStyle, new Color(FillColor));
|
iTextSharp.text.Font font = FontFactory.GetFont(Font.Name, BaseFont.IDENTITY_H,BaseFont.EMBEDDED, fontSize, fontStyle, new Color(FillColor));
|
||||||
|
|
||||||
Phrase ph = BuildPhrase(text, fontSize, fontStyle, font);
|
Phrase ph = BuildPhrase(text, fontSize, fontStyle, font);
|
||||||
ColumnText ct = new ColumnText(cb);
|
ColumnText ct = new ColumnText(cb);
|
||||||
@ -688,22 +688,22 @@ namespace Volian.Svg.Library
|
|||||||
if (m.Value.Contains(@"\b0"))
|
if (m.Value.Contains(@"\b0"))
|
||||||
{
|
{
|
||||||
fontStyle ^= iTextSharp.text.Font.BOLD;
|
fontStyle ^= iTextSharp.text.Font.BOLD;
|
||||||
font = FontFactory.GetFont(font.Familyname, BaseFont.IDENTITY_H, true, fontSize, fontStyle, new Color(FillColor));
|
font = FontFactory.GetFont(font.Familyname, BaseFont.IDENTITY_H, BaseFont.EMBEDDED, fontSize, fontStyle, new Color(FillColor));
|
||||||
}
|
}
|
||||||
else if (m.Value.Contains(@"\b"))
|
else if (m.Value.Contains(@"\b"))
|
||||||
{
|
{
|
||||||
fontStyle |= iTextSharp.text.Font.BOLD;
|
fontStyle |= iTextSharp.text.Font.BOLD;
|
||||||
font = FontFactory.GetFont(font.Familyname, BaseFont.IDENTITY_H, true, fontSize, fontStyle, new Color(FillColor));
|
font = FontFactory.GetFont(font.Familyname, BaseFont.IDENTITY_H, BaseFont.EMBEDDED, fontSize, fontStyle, new Color(FillColor));
|
||||||
}
|
}
|
||||||
if (m.Value.Contains(@"\i0"))
|
if (m.Value.Contains(@"\i0"))
|
||||||
{
|
{
|
||||||
fontStyle ^= iTextSharp.text.Font.ITALIC;
|
fontStyle ^= iTextSharp.text.Font.ITALIC;
|
||||||
font = FontFactory.GetFont(font.Familyname, BaseFont.IDENTITY_H, true, fontSize, fontStyle, new Color(FillColor));
|
font = FontFactory.GetFont(font.Familyname, BaseFont.IDENTITY_H, BaseFont.EMBEDDED, fontSize, fontStyle, new Color(FillColor));
|
||||||
}
|
}
|
||||||
else if (m.Value.Contains(@"\i"))
|
else if (m.Value.Contains(@"\i"))
|
||||||
{
|
{
|
||||||
fontStyle |= iTextSharp.text.Font.ITALIC;
|
fontStyle |= iTextSharp.text.Font.ITALIC;
|
||||||
font = FontFactory.GetFont(font.Familyname, BaseFont.IDENTITY_H, true, fontSize, fontStyle, new Color(FillColor));
|
font = FontFactory.GetFont(font.Familyname, BaseFont.IDENTITY_H, BaseFont.EMBEDDED, fontSize, fontStyle, new Color(FillColor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
text = next;
|
text = next;
|
||||||
@ -718,12 +718,12 @@ namespace Volian.Svg.Library
|
|||||||
if (font.BaseFont != null && font.BaseFont.GetWidthPoint("m", 12) == font.BaseFont.GetWidthPoint(".", 12))
|
if (font.BaseFont != null && font.BaseFont.GetWidthPoint("m", 12) == font.BaseFont.GetWidthPoint(".", 12))
|
||||||
{
|
{
|
||||||
VolianPdf.RegisterFont("VESymbFix");
|
VolianPdf.RegisterFont("VESymbFix");
|
||||||
fs.AddFont(FontFactory.GetFont("VESymbFix", BaseFont.IDENTITY_H, true, fontSize, fontStyle, new Color(FillColor)));
|
fs.AddFont(FontFactory.GetFont("VESymbFix", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, fontSize, fontStyle, new Color(FillColor)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
VolianPdf.RegisterFont("Arial Unicode MS");
|
VolianPdf.RegisterFont("Arial Unicode MS");
|
||||||
fs.AddFont(FontFactory.GetFont("Arial Unicode MS", BaseFont.IDENTITY_H, true, fontSize, fontStyle, new Color(FillColor)));
|
fs.AddFont(FontFactory.GetFont("Arial Unicode MS", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, fontSize, fontStyle, new Color(FillColor)));
|
||||||
}
|
}
|
||||||
|
|
||||||
Phrase ph = fs.Process(text);
|
Phrase ph = fs.Process(text);
|
||||||
@ -1088,7 +1088,7 @@ namespace Volian.Svg.Library
|
|||||||
private void SetTextLayout()
|
private void SetTextLayout()
|
||||||
{
|
{
|
||||||
Rectangle pageSize = _ContentByte.PdfWriter.PageSize; // Get page size
|
Rectangle pageSize = _ContentByte.PdfWriter.PageSize; // Get page size
|
||||||
_Basefont = BaseFont.CreateFont(BaseFont.HELVETICA_BOLD, Encoding.ASCII.EncodingName, false);
|
_Basefont = BaseFont.CreateFont(BaseFont.HELVETICA_BOLD, Encoding.ASCII.EncodingName, BaseFont.EMBEDDED);
|
||||||
float hgtA = _Basefont.GetAscentPoint(_Text, 12);
|
float hgtA = _Basefont.GetAscentPoint(_Text, 12);
|
||||||
//float hgtD = basefont.GetDescentPoint(text,20);
|
//float hgtD = basefont.GetDescentPoint(text,20);
|
||||||
float wid = _Basefont.GetWidthPointKerned(_Text, 12);
|
float wid = _Basefont.GetWidthPointKerned(_Text, 12);
|
||||||
@ -1156,7 +1156,7 @@ namespace Volian.Svg.Library
|
|||||||
}
|
}
|
||||||
public void SetTextPattern2(float fontSize)
|
public void SetTextPattern2(float fontSize)
|
||||||
{
|
{
|
||||||
BaseFont _Basefont2 = BaseFont.CreateFont(BaseFont.HELVETICA, Encoding.ASCII.EncodingName, false);
|
BaseFont _Basefont2 = BaseFont.CreateFont(BaseFont.HELVETICA, Encoding.ASCII.EncodingName, BaseFont.EMBEDDED);
|
||||||
float hgtA = _Basefont2.GetAscentPoint(_Text, fontSize);
|
float hgtA = _Basefont2.GetAscentPoint(_Text, fontSize);
|
||||||
float wid = _Basefont2.GetWidthPointKerned(_Text, fontSize);
|
float wid = _Basefont2.GetWidthPointKerned(_Text, fontSize);
|
||||||
_PatternPainter = _ContentByte.CreatePattern(wid * 2, hgtA * 2, wid * 2, hgtA * 2);
|
_PatternPainter = _ContentByte.CreatePattern(wid * 2, hgtA * 2, wid * 2, hgtA * 2);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user