B2019-152: landscape page numbers for print all/merge
This commit is contained in:
@@ -74,7 +74,7 @@ namespace Volian.Print.Library
|
||||
_docVersionInfo = dvi;
|
||||
}
|
||||
// the following merges the procedure pdfs into a single pdf
|
||||
public bool DoTheMerge()
|
||||
public bool DoTheMerge(Dictionary<string, List<int>> MergedLandscapPages)
|
||||
{
|
||||
if (MergedPdfs == null)
|
||||
{
|
||||
@@ -117,6 +117,15 @@ namespace Volian.Print.Library
|
||||
FlexibleMessageBox.Show("Error in finding pdf files to merge. Cannot print with date/time as part of pdf name. Or check that individual pdfs were generated.", "Error on CreatePdf", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
return false;
|
||||
}
|
||||
// B2019-152: The MergedLandscapePages Dictionary contains page numbers for pdfs that need to be landscaped. These are
|
||||
// added on 'endpages' when printing is done.
|
||||
List<int> LandscapePages = null; // List of landscaped pages for a pdf
|
||||
if (PromsPrinter.MergedLandscapePages != null)
|
||||
{
|
||||
string fname = mpp.PdfFileName.Substring(0, mpp.PdfFileName.IndexOf(".pdf"));
|
||||
if (PromsPrinter.MergedLandscapePages.ContainsKey(fname))
|
||||
LandscapePages = PromsPrinter.MergedLandscapePages[fname];
|
||||
}
|
||||
PdfReader reader = null;
|
||||
try // B2019-041: added a try/catch for when a corrupt pdf was created for a procedure, just skip & add message to error log.
|
||||
{
|
||||
@@ -134,8 +143,10 @@ namespace Volian.Print.Library
|
||||
PdfImportedPage page = writer.GetImportedPage(reader, currentPageNumber); // gets a page that is 'ready' to be written to combined pdf
|
||||
if (doPageNum) // get the string & fill in with <page> and <of> numbers
|
||||
{
|
||||
bool landscape = false;
|
||||
if (LandscapePages != null && LandscapePages.Contains(currentPageNumber - 1)) landscape = true;
|
||||
string outputpageof = _pageof.Replace("<page>", mergedPageNumber.ToString()).Replace("<of>", totalPages.ToString());
|
||||
AddPageNumberToPage(page, canvas, outputpageof);
|
||||
AddPageNumberToPage(page, canvas, outputpageof, landscape);
|
||||
}
|
||||
PdfDestination dest = new PdfDestination(PdfDestination.FIT);
|
||||
// if on the first page, add the pdfname & title as part of outline. If on remaining pages, just put out page number.
|
||||
@@ -158,36 +169,78 @@ namespace Volian.Print.Library
|
||||
}
|
||||
// this method adds the page number to the page before it is merged in. It determines the position from the properties
|
||||
// that were set on the doc version properties dialog (these values were set as local class variables from GetPageOfInfo)
|
||||
private void AddPageNumberToPage(PdfImportedPage page, PdfContentByte cb, string outputpage)
|
||||
private void AddPageNumberToPage(PdfImportedPage page, PdfContentByte cb, string outputpage, bool landscape)
|
||||
{
|
||||
float pgright = page.BoundingBox.Right;
|
||||
float pgleft = page.BoundingBox.Left;
|
||||
float pgtop = page.BoundingBox.Top;
|
||||
float pgbot = page.BoundingBox.Bottom;
|
||||
// B2019-152: Landscape page numbers when merging
|
||||
if (landscape)
|
||||
{
|
||||
pgright = page.BoundingBox.Top;
|
||||
pgleft = page.BoundingBox.Bottom;
|
||||
pgtop = page.BoundingBox.Right;
|
||||
pgbot = page.BoundingBox.Left;
|
||||
}
|
||||
Phrase ph = new Phrase();
|
||||
Chunk chk = new Chunk(outputpage, _itextFont);
|
||||
ph.Add(chk);
|
||||
Paragraph pg = new Paragraph(ph);
|
||||
ColumnText columnText = new ColumnText(cb);
|
||||
cb.SaveState();
|
||||
switch (_corner)
|
||||
{
|
||||
case MergedPdfsPageNumCorner.TopRight:
|
||||
columnText.Alignment = Element.ALIGN_RIGHT;
|
||||
columnText.SetSimpleColumn(0, pgtop - _yloc, pgright - _xloc, 0);
|
||||
if (landscape) // B2019-152: landscape page numbers
|
||||
{
|
||||
System.Drawing.Drawing2D.Matrix myMatrix1 = new System.Drawing.Drawing2D.Matrix(0, 1, -1, 0, cb.PdfDocument.PageSize.Height, 0);
|
||||
cb.Transform(myMatrix1);
|
||||
columnText.SetSimpleColumn(0, pgright - _yloc, pgright - _xloc, 0);
|
||||
}
|
||||
else
|
||||
columnText.SetSimpleColumn(0, pgtop - _yloc, pgright - _xloc, 0);
|
||||
break;
|
||||
case MergedPdfsPageNumCorner.BottomRight:
|
||||
columnText.Alignment = Element.ALIGN_RIGHT;
|
||||
columnText.SetSimpleColumn(0, _yloc, pgright - _xloc, 0);
|
||||
if (landscape) // B2019-152: landscape page numbers
|
||||
{
|
||||
System.Drawing.Drawing2D.Matrix myMatrix2 = new System.Drawing.Drawing2D.Matrix(0, 1, -1, 0, cb.PdfDocument.PageSize.Width, 0);
|
||||
cb.Transform(myMatrix2);
|
||||
columnText.SetSimpleColumn(0, _yloc, pgright - _xloc, 0);
|
||||
}
|
||||
else
|
||||
columnText.SetSimpleColumn(0, _yloc, pgright - _xloc, 0);
|
||||
break;
|
||||
case MergedPdfsPageNumCorner.TopLeft:
|
||||
columnText.SetSimpleColumn(_xloc, pgtop - _yloc, pgright, 0); // page alignment defaults to ALIGN_LEFT
|
||||
if (landscape) // B2019-152: landscape page numbers
|
||||
{
|
||||
System.Drawing.Drawing2D.Matrix myMatrix3 = new System.Drawing.Drawing2D.Matrix(0, 1, -1, 0, cb.PdfDocument.PageSize.Height, 0);
|
||||
cb.Transform(myMatrix3);
|
||||
columnText.SetSimpleColumn(_xloc, pgright - _yloc, pgright - _xloc, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
columnText.SetSimpleColumn(_xloc, pgtop - _yloc, pgright, 0); // page alignment defaults to ALIGN_LEFT
|
||||
}
|
||||
break;
|
||||
case MergedPdfsPageNumCorner.BottomLeft:
|
||||
columnText.SetSimpleColumn(_xloc, _yloc, pgright, 0); // page alignment defaults to ALIGN_LEFT
|
||||
if (landscape) // B2019-152: landscape page numbers
|
||||
{
|
||||
System.Drawing.Drawing2D.Matrix myMatrix4 = new System.Drawing.Drawing2D.Matrix(0, 1, -1, 0, cb.PdfDocument.PageSize.Width, 0);
|
||||
cb.Transform(myMatrix4);
|
||||
columnText.SetSimpleColumn(_xloc, _yloc, pgright - _xloc, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
columnText.SetSimpleColumn(_xloc, _yloc, pgright, 0); // page alignment defaults to ALIGN_LEFT
|
||||
}
|
||||
break;
|
||||
}
|
||||
columnText.AddText(pg);
|
||||
columnText.Go();
|
||||
cb.RestoreState();
|
||||
}
|
||||
// this method gets the format, font & location data from the doc version properties that are stored on the doc version's
|
||||
// config field. It saves them as local class variables to be used in other places in this class.
|
||||
|
@@ -272,9 +272,14 @@ namespace Volian.Print.Library
|
||||
get { return _MergeNotIncluded; }
|
||||
set { _MergeNotIncluded = value; }
|
||||
}
|
||||
|
||||
private MergedPdf _MergedPdf;
|
||||
public MergedPdf MergedPdf
|
||||
{
|
||||
get { return _MergedPdf; }
|
||||
set { _MergedPdf = value; }
|
||||
}
|
||||
public PromsPrinter(ItemInfo myItem, string rev, string watermark, bool debugOutput, bool origPgBrk, string backgroundFolder, bool openPDF, bool overWrite,
|
||||
ChangeBarDefinition cbd, String pdfFile, bool insertBlankPages, bool batchPrint, string prefix, bool saveLinks, bool removeTrailngHardReturnsAndManualPageBreaks, string blankPageText, bool didAll)
|
||||
ChangeBarDefinition cbd, String pdfFile, bool insertBlankPages, bool batchPrint, string prefix, bool saveLinks, bool removeTrailngHardReturnsAndManualPageBreaks, string blankPageText, bool didAll, MergedPdf mergedPdf)
|
||||
{
|
||||
Prefix = prefix; // RHM20150506 Multiline ItemID TextBox
|
||||
_MyItem = myItem;
|
||||
@@ -295,6 +300,7 @@ namespace Volian.Print.Library
|
||||
_BlankPageText = blankPageText;
|
||||
_DidAll = didAll;
|
||||
_MergeNotIncluded = false;
|
||||
_MergedPdf = mergedPdf;
|
||||
//_MyReaderHelper.LoadTree(myItem);
|
||||
}
|
||||
// Pass 1 PDF Name
|
||||
@@ -311,6 +317,9 @@ namespace Volian.Print.Library
|
||||
get { return _BeforePageNumber2Pdf; }
|
||||
set { _BeforePageNumber2Pdf = value; }
|
||||
}
|
||||
// B2019-152: MergedLandscapePages is a dictionary whose key is the pdf file name & values are all of the page numbers
|
||||
// in that pdf that should have landscaped page numbers. These are added when the page is finished (onEndPage)
|
||||
public static Dictionary<string, List<int>> MergedLandscapePages = null;
|
||||
public string Print(string pdfFolder, bool makePlacekeeper, bool makeContinuousActionSummary)
|
||||
{
|
||||
if (_MyItem is ProcedureInfo)
|
||||
@@ -1273,6 +1282,22 @@ namespace Volian.Print.Library
|
||||
}
|
||||
ProfileTimer.Pop(profileDepth);
|
||||
}
|
||||
// B2019-152: AddMergedLandscapePage adds entries to the dictionary that keeps track of what pages in a pdf are landscape
|
||||
// so that if merge is done, the pages that are landscaped can have landscaped page numbers placed on them
|
||||
public static void AddMergedLandscapePage(VlnSvgPageHelper _MyHelper, string PDFFile)
|
||||
{
|
||||
string tmp = PDFFile.Substring(0,PDFFile.IndexOf(".pdf"));
|
||||
if (MergedLandscapePages == null) MergedLandscapePages = new Dictionary<string, List<int>>();
|
||||
if (MergedLandscapePages.ContainsKey(tmp))
|
||||
MergedLandscapePages[tmp].Add(_MyHelper.CurrentPageNumber);
|
||||
else
|
||||
{
|
||||
// Create the list & add this to dictionary, pdf file with page list.
|
||||
List<int> children = new List<int>();
|
||||
children.Add(_MyHelper.CurrentPageNumber);
|
||||
MergedLandscapePages.Add(tmp, children);
|
||||
}
|
||||
}
|
||||
private void GenerateTOC(SectionInfo tocSection, ProcedureInfo myProcedure, PdfContentByte cb, PdfLayer textLayer)
|
||||
{
|
||||
iTextSharp.text.pdf.PdfWriter writer = cb.PdfWriter;
|
||||
|
@@ -249,6 +249,8 @@ namespace Volian.Print.Library
|
||||
int profileDepth = ProfileTimer.Push(">>>> OnEndPage");
|
||||
InitialsPrinted = false;
|
||||
MyPromsPrinter.OnStatusChanged(string.Format("Page {0}", CurrentPageNumber+1));
|
||||
// B2019-152: Landscape page merged page numbers
|
||||
if (this.MySection != null && MySection.MyDocStyle.LandscapePageList) PromsPrinter.AddMergedLandscapePage(this, MyPromsPrinter.PDFFile);
|
||||
bool onBlankPage = OnBlankPage;
|
||||
if (OnBlankPage)
|
||||
{
|
||||
|
Reference in New Issue
Block a user