Wed May 22, 2019 2:48 am
Good day!
My scenario is that I am creating the Image file first in another Method. Should I put the reset resolution before it converts to image?
This one is converting the document file to image this is the first step:
internal void InserAttachments(Spire.Doc.Document doc, int id, int modulepageId = 0)
{
....//some code
for (int x = 0; x < document.PageCount; x++)
{
Image imageDocument = document.SaveToImages(x, Spire.Doc.Documents.ImageType.Metafile);
imageDocument.Save(downloadPath + "_" + repFIleName + "_" + x + ".jpg", System.Drawing.Imaging.ImageFormat.Bmp);
}
}
Second step was Iwill put the save image file to a new page and I am setting it to default resolution, I draw a line and put a page number below the page also I wonder if this could take effect on the resolution and quality of the image of the file:
internal void CreatNewPageforAttachment(Spire.Doc.Document doc, int id)
{
Section s = doc.AddSection();
Paragraph p = s.AddParagraph();
//Insert Image and Set Its Size
DocPicture Pic = p.AppendPicture(Image.FromFile(list[x]));
Pic.Width = 550;
Pic.Height = 662;
var pageCount = doccount + 1;
s.PageSetup.Margins.Left = 25.9f;
s.PageSetup.Margins.Right = 60.9f;
//s.HeadersFooters.Header.ChildObjects.Clear();
//s.Document.LastSection.HeadersFooters.Header.ChildObjects.Clear();
s.PageSetup.DifferentFirstPageHeaderFooter = true;
s.PageSetup.DifferentOddAndEvenPagesHeaderFooter = false;
//// doc.Sections[x+1].HeadersFooters.Header.ChildObjects.Clear();
s.HeadersFooters.FirstPageHeader.ChildObjects.Clear();
s.HeadersFooters.LinkToPrevious = false;
Table table2 = s.AddTable(true);
table2.ResetCells(1, 4);
//table2.TableFormat.Borders.Color = Color.White;
table2.TableFormat.Borders.Left.Color = Color.White;
table2.TableFormat.Borders.Right.Color = Color.White;
table2.TableFormat.Borders.Bottom.Color = Color.White;
table2.TableFormat.Borders.Vertical.Color = Color.White;
Paragraph p1 = table2[0, 0].AddParagraph();
table2.Rows[0].Cells[0].Width = 140;
Spire.Doc.Fields.TextRange t2 = p1.AppendText("");
p1.Format.HorizontalAlignment = HorizontalAlignment.Left;
Paragraph p2 = table2[0, 1].AddParagraph();
Spire.Doc.Fields.TextRange t3 = p2.AppendText("");
p2.Format.HorizontalAlignment = HorizontalAlignment.Center;
Paragraph p3 = table2[0, 2].AddParagraph();
Spire.Doc.Fields.TextRange t4 = p3.AppendText("");
p3.Format.HorizontalAlignment = HorizontalAlignment.Center;
Paragraph p4 = table2[0, 3].AddParagraph();
Spire.Doc.Fields.TextRange t5 = p4.AppendText("Page " +(pageCount + x) + " of " + totalpage);
p4.Format.HorizontalAlignment = HorizontalAlignment.Center;
table2.TableFormat.Positioning.HorizPositionAbs = HorizontalPosition.Outside;
table2.TableFormat.Positioning.VertRelationTo = VerticalRelation.Margin;
table2.TableFormat.Positioning.VertPosition = 730;
table2.TableFormat.Positioning.HorizPosition = 16;
}
}