I need to insert a series of different small pdf “Snippets” into a larger pdf page that I am creating.
I am using this code. I am not sure that the a and d values of the matrix are correct.
Also,
I need to insert the pdf snippet rotated.
here is my attempt to insert a small pdf snippet into a larger pdf file.
public static void ExecInsertImageTest()
{
Aspose.Pdf.Document doc = new Document();
Aspose.Pdf.Page p = doc.Pages.Add();
p.PageInfo.Height = 11.0f * 72.0f;
p.PageInfo.Width = 8.5f * 72.0f;
p.PageInfo.Margin.Bottom = 0.0f;
p.PageInfo.Margin.Top = 0.0f;
p.PageInfo.Margin.Left = 0.0f;
p.PageInfo.Margin.Right = 0.0f;
FileStream ifs = new FileStream("SnippetFileName.pdf", FileMode.Open);
p.Resources.Images.Add(ifs);
p.Contents.Add(new Aspose.Pdf.Operators.GSave());
Aspose.Pdf.Rectangle rect = new Aspose.Pdf.Rectangle(447.3f, 703.1475, 594.36f,768.338f);
Aspose.Pdf.Matrix ma = new Aspose.Pdf.Matrix(new double[]
{
147.06f, 0f, 0f, 65.1905f,
447.3f, 703.145f
});
p.Contents.Add(new Aspose.Pdf.Operators.ConcatenateMatrix(ma));
Aspose.Pdf.XImage xi = p.Resources.Images[p.Resources.Images.Count];
p.Contents.Add(new Aspose.Pdf.Operators.Do(xi.Name));
p.Contents.Add(new Aspose.Pdf.Operators.GRestore());
doc.Save("Example File.pdf");
}
Title Block ssmall.pdf (100.3 KB)